2013-07-17 7 views
0

옵션 시트를 표시했을 때 키보드 숨기기에 문제가 있습니다.ios 앱에서 키보드 숨기기

내 코드의 문제는 어디에 있습니까?

- (void)optionsSheet2{ 

    if(optionsSheet2) { 
     [optionsSheet2 dismissWithClickedButtonIndex:-1 animated:YES]; 
     optionsSheet2 = nil; 
    } 

    optionsSheet2 = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:NSLocalizedString(@"Cancel", nil) destructiveButtonTitle:nil otherButtonTitles:NSLocalizedString(@"Delete", nil), NSLocalizedString(@"Delete all", nil), nil]; 

    [optionsSheet2 showInView:self.parentViewController.view]; 
} 

- (void)dismissKeyboard { 
    [_uiSearchBar resignFirstResponder]; 
    [_uiSearchBar setShowsCancelButton:NO animated:YES]; 
    [_uiSearchBar setHidden:true]; 
    [self.view endEditing:YES]; 
} 
+0

위임 방법을 올바르게 추가 했습니까? –

+0

U 좀 더 명확 abt UR 질문 수 있습니까? – Kasaname

+0

UIActionSheetDelegate 및 UISearchBarDelegate가 있습니다. – Unmerciful

답변

1

당신은 다음과 같이 코드를 변경 :

- (void)optionsSheet2 
    { 
    [self.view endEditing:YES]; 
    } 
+0

작동하지 않습니다. – Unmerciful

+0

이 라인 코드를 확인하십시오 : [self.parentViewController.view endEditing : YES]; –

+0

너무 효과적이지 않습니다. ( 옵션 시트를 사용하지 않으면 작동합니다. – Unmerciful

0

사용이 간단한 솔루션의 UITextField, UITextView 모든 서브 뷰와

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event 
{ 
    [self.view endEditing:YES]; 
} 

작품.