UIPopoverViewController 添加子视图很慢

发布于 2024-12-11 14:41:42 字数 888 浏览 4 评论 0原文

我有一个 UIPopoverViewController 可以正确显示自定义 UIViewController 。当我单击按钮时,我会运行一个操作,因此我将一个视图添加到 UIViewController 视图的视图层次结构中。

问题是它非常慢,需要几秒钟才能显示视图。我没有对 UIViewController 的代码做任何不寻常的事情。

- (void)showAccountChooser {
    self.twitterAccountPicker = [TwitterAccountPicker new];
    [self.view addSubview:self.twitterAccountPicker.view];
    self.twitterAccountPicker.view.frame = self.view.bounds;

    self.twitterAccountPicker.view.transform = CGAffineTransformMakeScale(.05, .05);

    [UIView animateWithDuration:0.5f animations:^{
        self.twitterAccountPicker.view.transform = CGAffineTransformMakeScale(1, 1);
    } completion:^(BOOL finished) {
        //[self.twitterAccountPicker viewDidAppear:YES];
    }];
}

我添加的 UIViewController 很简单,并且不会在 viewDidLoad 或 viewWill/DidAppear 中进行繁重的处理。我已经设置了断点并验证它没有做任何的事情。

还有其他人在添加视图时注意到这一点吗?

I have a UIPopoverViewController that is displaying a custom UIViewController properly. When I click a button I have an action run and as a result I add a view to the view hierarchy of the UIViewController's view.

The problem is that it is very slow, and takes several seconds for the view to appear. I'm not doing anything out of the ordinary with my UIViewController's code.

- (void)showAccountChooser {
    self.twitterAccountPicker = [TwitterAccountPicker new];
    [self.view addSubview:self.twitterAccountPicker.view];
    self.twitterAccountPicker.view.frame = self.view.bounds;

    self.twitterAccountPicker.view.transform = CGAffineTransformMakeScale(.05, .05);

    [UIView animateWithDuration:0.5f animations:^{
        self.twitterAccountPicker.view.transform = CGAffineTransformMakeScale(1, 1);
    } completion:^(BOOL finished) {
        //[self.twitterAccountPicker viewDidAppear:YES];
    }];
}

The UIViewController that I'm adding is trivial and does not heavy processing in the viewDidLoad or viewWill/DidAppear. I have set break points and verified that it is not doing anything bad.

Anyone else notice this when adding views?

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

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

发布评论

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

评论(1

为你拒绝所有暧昧 2024-12-18 14:41:42

设置断点尝试调试此问题后,我意识到我的 showAccountChooser 方法是从块调用中调用的,这是在后台线程上发生的。将此调用移至主线程解决了该问题。

After setting break points trying to debug this, I realized that my showAccountChooser method was being called from a block invoke, which was happening on a background thread. Moving this call to the main thread resolved the issue.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文