我做些什麼來避免文本框被覆蓋的鍵盤當用戶觸摸它的文本框動畫在屏幕的頂部開始通過鍵盤輸入內容並在完成後將其回放。我認爲它更優雅。也許這可能是你的替代解決方案。我做它用不同的號碼不同screensizes ......你可能需要調整它,當然......
所以聽的文本字段代表和
- (void)textFieldDidBeginEditing:(UITextField *)textField {
你做
CGSize result = [[UIScreen mainScreen] bounds].size;
if(result.height == 480){
({[UIView beginAnimations:nil context:NULL]; [UIView setAnimationDuration:0.35f]; CGRect frame = self.view.frame; frame.origin.y = -196; [self.view setFrame:frame]; [UIView commitAnimations];});
}
if(result.height == 568){
({[UIView beginAnimations:nil context:NULL]; [UIView setAnimationDuration:0.35f]; CGRect frame = self.view.frame; frame.origin.y = -196; [self.view setFrame:frame]; [UIView commitAnimations];});
}
if(result.height == 667){
({[UIView beginAnimations:nil context:NULL]; [UIView setAnimationDuration:0.35f]; CGRect frame = self.view.frame; frame.origin.y = -238; [self.view setFrame:frame]; [UIView commitAnimations];});
}
if(result.height == 736){
({[UIView beginAnimations:nil context:NULL]; [UIView setAnimationDuration:0.35f]; CGRect frame = self.view.frame; frame.origin.y = -251; [self.view setFrame:frame]; [UIView commitAnimations];});
}
和
- (void)textFieldDidEndEditing:(UITextField *)textField {
你只是BA動畫ck
({[UIView beginAnimations:nil context:NULL]; [UIView setAnimationDuration:0.35f]; CGRect frame = self.view.frame; frame.origin.y = 0; [self.view setFrame:frame]; [UIView commitAnimations];});
你能顯示/發佈你的代碼嗎? –
您是否在添加內容後設置了滾動視圖的contentSize? –