2013-01-04 3 views
1

내 iPhone 응용 프로그램에서. MFMailComposerView보기에서 수신자를 클릭하면 키 보드가 나타납니다. 키보드에서 return 키를 클릭하면됩니다. 그러나 키보드는 사라지지 않습니다.mfmailcomposerview에서 키보드를 닫는 법

+0

아니요 키보드를 절대로 무시할 수 없습니다 –

+0

일부 재귀 응답 체인 해킹으로 인해 iOS 6 이전 버전에서 작동하지만 메일 컨트롤러가 원격이므로 이제는 응답자를 원격으로 사칭하려고 시도 할 수는 없습니다. – CodaFi

+0

나는 리턴 키가 한 텍스트 필드에서 MFMailComposerView의 다른 텍스트 필드로 이동한다고 생각한다. 마지막 텍스트 필드는 리턴한다. –

답변

0

다음 코드를 사용할 수 있습니다. 앱에서이를 사용하는 경우 UIWindow의 firstResponder 방법은 개인 API이기 때문에

UIWindow *mainWin = [[UIApplication sharedApplication] keyWindow]; 
UIView *responder = [mainWin performSelector:@selector(firstResponder)]; 
[responder resignFirstResponder]; 

하지만, 애플은 확실히 당신의 응용 프로그램을 거부합니다.

참조 : SO

+2

이 답변의 사본에 대한 atlist 링크를 넣어주십시오 : - http://stackoverflow.com/questions/4872565/mfmailcomposeviewcontroller-keyboard-issue –

3

사용 UIWindow 알림 키보드와 단지에 .. 표시합니다 MFMailComposerViewController에 대한 울부 짖는 코드를 사용

- (IBAction)showMailController { 
    //Present mail controller on press of a button, set up notification of keyboard showing and hiding 
    [nc addObserver:self selector:@selector(keyboardWillShow:) name: UIKeyboardWillShowNotification object:nil]; 
    [nc addObserver:self selector:@selector(keyboardWillHide:) name: UIKeyboardWillHideNotification object:nil]; 
    MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];   
    //... and so on 
}   
- (void)keyboardWillShow:(NSNotification *)note { 
    //Get view that's controlling the keyboard 
    UIWindow* keyWindow = [[UIApplication sharedApplication] keyWindow]; 
    UIView* firstResponder = [keyWindow performSelector:@selector(firstResponder)]; 

    //set up dimensions of dismiss keyboard button and animate it into view, parameters are based on landscape orientation, the keyboard's dimensions and this button's specific dimensions 
    CGRect t; 
    [[note.userInfo valueForKey:UIKeyboardBoundsUserInfoKey] getValue: &t]; 
    button.frame = CGRectMake(324,(290-t.size.height),156,37); 
    button.alpha = 0.0; 
    [UIView beginAnimations:nil context:NULL]; 
    [UIView setAnimationDuration:1.0];  
    [[[[[firstResponder superview] superview] superview] superview] addSubview:button]; 
    button.alpha = 1.0; 
    button.frame = CGRectMake(324,(253-t.size.height),156,37); 
    [UIView commitAnimations]; 
} 

- (IBAction)dismissKeyboardInMailView { 
    //this is what gets called when the dismiss keyboard button is pressed 
    UIWindow* keyWindow = [[UIApplication sharedApplication] keyWindow]; 
    UIView* firstResponder = [keyWindow performSelector:@selector(firstResponder)]; 
    [firstResponder resignFirstResponder]; 
} 

- (void)keyboardWillHide:(NSNotification *)note { 
    //hide button here 
    [button removeFromSuperview]; 
} 

내가이 링크에서이 코드의 일부를 가지고

..

programmatically-align-a-toolbar-on-top-of-the-iphone-keyboard

+1

@NitinGohel 위의 해고 코드는 어떨까요? 이 코드는 http://stackoverflow.com/questions/4872565/mfmailcompleviewcontroller-keyboard-issue에서 사용 된 코드와 완전히 동일합니다. –

관련 문제