0

UIKeyboardは、iOS8以降で正常に動作する通知方法を表示したり非表示にしたりしますが、iOS7では機能しません。何か別の選択肢はありますか?UIKeyboardWillShowNotificationがiOS 7で動作しない

マイアプリケーションの展開先はiOS7です。

マイコードは、ここで事前に

- (void)viewDidLoad 
{ 
[[NSNotificationCenter defaultCenter] addObserver:self 
              selector:@selector(keyboardWasShown:) 
               name:UIKeyboardWillShowNotification 
               object:nil]; 

    [[NSNotificationCenter defaultCenter] addObserver:self 
              selector:@selector(HideKeyboard:) 
               name:UIKeyboardWillHideNotification 
               object:nil]; 
} 

- (void)keyboardWasShown:(NSNotification *)sender 
{ 
    CGSize kbSize = 
     [[[sender userInfo] objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue].size; 

    if (!scroll) { 
     scrollValue = self.WholeScreenUIView.frame.origin.y - kbSize.height; 
    } 

    scroll = YES; 
} 

- (void)HideKeyboard:(NSNotification *)sender 
{ 

    scroll = NO; 

    scrollValue = 0.0; 
} 

おかげです。

+0

はあなたが動作しないで手の込んだことはできますか?このメソッドはiOS 7で呼び出されますか? – rckoenes

答えて

0

使用このコード..

[[NSNotificationCenter defaultCenter] addObserver:self 
               selector:@selector(keyboardWillHideHandler:) 
                name:UIKeyboardWillHideNotification 
                object:nil]; 

    [[NSNotificationCenter defaultCenter] addObserver:self 
              selector:@selector(keyboardWillshowHandler:) 
               name:UIKeyboardWillShowNotification 
               object:nil]; 

- (void) keyboardWillHideHandler:(NSNotification *)notification { 
    [scroll setContentOffset:CGPointMake(0, 0) animated:YES]; 
} 

- (void) keyboardWillshowHandler:(NSNotification *)notification { 
    [scroll setContentSize:CGSizeMake(self.view.frame.size.width, self.view.frame.size.height+44)]; 

} 

希望このhelps.Thisは、私の場合で動作

+0

このコードは、オブザーバーコードがどのメソッドにも配置されていないという点を除いて、問題は変わりません。 – rckoenes

+0

あなたのサポートありがとう、上記のコードはiOS 8で動作しますが、iOS 7では動作しませんでした。 FYI:iOS 7ではオブザーバ関数が呼び出されていません – Sakthi

関連する問題