【发布时间】:2016-03-06 07:30:10
【问题描述】:
从过去几天开始,我遇到了一个奇怪的 keyboard 问题,该问题仅在 iPhone 5c 中发生。
我在Xcode-6.4 中使用objective-C 进行开发
我的环境目标是ios7。
这是我处理keyboard Notification的方式。
- (void)viewDidAppear:(BOOL)animated{
[super viewDidAppear:animated];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil];
}
致Deregister Notification 我正在编写这段代码。确保我对每个文本字段都使用-resignFirstResponder。
- (void)viewWillDisappear:(BOOL)animated{
[super viewWillDisappear:animated];
[self hideKeyBoard];
[self.view endEditing:YES];
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillShowNotification object:nil];
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillHideNotification object:nil];
}
- (void)hideKeyBoard{
[kAgeTextField resignFirstResponder];
[kSchoolTextField resignFirstResponder];
}
在提交按钮中,我检查了一些条件,然后显示AlertView。
- (IBAction)submitClicked:(id)sender
{
if(validated)
{
[self.view endEditing:YES];
[self hideKeyBoard];
[self.view resignFirstResponder];
[self makeApiCall];
}
}
现在,当我从服务器获得成功/失败响应时,我正在这样做。这是在从服务器获得响应后运行的块:
-(void)SuccessfulWithServerInfo:(id)responseInfo
{
AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
dispatch_async(dispatch_get_main_queue(),^{
[appDelegate hideProgressViewFromView:self.view];
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"" message:@"Thanks for coming" delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil];
[alert show];
[self.navigationController popToRootViewControllerAnimated:YES];
});
}
问题当我得到 alertBox 并按确定时。然后键盘会自动打开和关闭。这仅在 iPhone 5C 上发生。我在 4s、5s、6 和 6Plus 中检查了它。一切正常。
如果有人知道,请提供帮助。
【问题讨论】:
标签: ios objective-c iphone keyboard uikeyboard