我有一个动作,允许我呈现一个ModalViewController并显示UITextField作为第一响应者,问题是当这个ModalViewController出现时需要一点时间,原因是键盘,当我抓住代码到viewDidAppear键盘需要一点时间才能显示出来,那么我怎样才能让UIViewController快速启动呢?
- (IBAction)goToModalViewController
{
ModalSearchViewController *msvc = [[ModalSearchViewController alloc] init];
self.msvc.context = context;
self.msvc.delegate = self;
[self.msvc setModalTransitionStyle:UIModalTransitionStyleCrossDissolve ];
[self presentModalViewController:msvc animated:YES];
}
ModalViewController的viewWillAppear:
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:YES];
[findTextField becomeFirstResponder];
}
答案 0 :(得分:1)
在viewWillAppear
中尝试这样做。
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
//[findTextField becomeFirstResponder];
[findTextField performSelector:@selector(becomeFirstResponder) withObject:nil afterDelay:0.3];
}