1
我使用下面的atm代碼。只要你沒有退出應用程序(按回家)鍵盤啓動,它工作正常。所以我認爲,簡單,只是resignFirstResponder在viewWillDissappear :(BOOL)動畫,但不會被稱爲明顯按下家...移動鍵盤的視圖,然後按住home鍵,返回以查看未轉換視圖中的結果?
因此,快速回顧一下問題場景: 點擊textView - >鍵盤出現,觀點再次轉移 按家庭 打開應用程序 - >鍵盤仍然上漲,看法是背它在哪裏,所以內容不可見
- (void)viewDidLoad
{
[super viewDidLoad];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil];
}
- (void) keyboardWillShow: (NSNotification*) aNotification;
{
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.3];
CGRect rect = [[self view] frame];
rect.origin.y -= 60;
[[self view] setFrame: rect];
[UIView commitAnimations];
}
- (void) keyboardWillHide: (NSNotification*) aNotification;
{
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.3];
CGRect rect = [[self view] frame];
rect.origin.y += 60;
[[self view] setFrame: rect];
[UIView commitAnimations];
}