键盘使 UIView 出现时速度变慢?

发布于 2024-12-24 19:32:25 字数 1055 浏览 0 评论 0原文

我有一个操作允许我呈现 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]; 
}

i have an action that allows me to present a ModalViewController and show the UITextField as a first responder, the problem is when this ModalViewController will come up it takes a little time, the cause is the keyboard, and when i grab the code to the viewDidAppear the keyboard take a little time to show up, so how can i do to make the UIViewController comes up quickly?

- (IBAction)goToModalViewController
{    
    ModalSearchViewController *msvc = [[ModalSearchViewController alloc] init];
    self.msvc.context = context;
    self.msvc.delegate = self;
    [self.msvc setModalTransitionStyle:UIModalTransitionStyleCrossDissolve ];                                                                                                                                                                                                                                                                                                                                                       
    [self presentModalViewController:msvc animated:YES];
}

The viewWillAppear of the ModalViewController:

- (void)viewWillAppear:(BOOL)animated
{
   [super viewWillAppear:YES];

   [findTextField becomeFirstResponder]; 
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

勿忘初心 2024-12-31 19:32:25

viewWillAppear 中尝试这样做。

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];

    //[findTextField becomeFirstResponder]; 
    [findTextField performSelector:@selector(becomeFirstResponder) withObject:nil afterDelay:0.3];
}

Try like this in the viewWillAppear.

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];

    //[findTextField becomeFirstResponder]; 
    [findTextField performSelector:@selector(becomeFirstResponder) withObject:nil afterDelay:0.3];
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文