cra*_*gen 5 objective-c ipad ios resignfirstresponder
我试图在iPad上隐藏键盘,但我不知道为什么resignFirstResponder不起作用.但popToRoot运作良好.
- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
NSString *desc = [NSString stringWithFormat:@"%@",[descTF text]];
[textField resignFirstResponder];
[self.navigationController popToRootViewControllerAnimated:YES];
return YES;
}
Run Code Online (Sandbox Code Playgroud)
那么你能指导我该怎么办?
sam*_*tte 19
这个字段在里面UIModalPresentationFormSheet吗?如果是这样,那么在视图控制器被解除之前,您无法以编程方式解除键盘问题.
更新:根据Apple Developer Forums的这个主题,可能的解决方法是从实现disablesAutomaticKeyboardDismissal方法的导航控制器子类内部呈现工作表视图控件.所以类似于:
MyViewController *myViewController = [[MyViewController alloc] initWithNibName:@"MyViewController" bundle:nil];
CustomNavigationController *navController = [[CustomNavigationController alloc] initWithRootViewController:myViewController];
theNavigationController.modalPresentationStyle = UIModalPresentationFormSheet;
[self presentModalViewController:theNavigationController animated:YES];
Run Code Online (Sandbox Code Playgroud)
要跟进samvermette的答案,如果它在UIModalPresentationFormSheet你的内部,你现在可以覆盖disablesAutomaticKeyboardDismissal方法以获得你想要的行为.将以下方法添加到您的类中,UITextFields并且UITextViews将响应resignFirstResponder.
- (BOOL)disablesAutomaticKeyboardDismissal {
return NO;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3863 次 |
| 最近记录: |