解决方法- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
[self presentViewController:[[YourViewController alloc] init] animated:YES completion:NULL];
}
或者:
- (void)viewDidLoad
{
[super viewDidLoad];
dispatch_async(dispatch_get_main_queue(), ^{
YourViewController *v = [[YourViewController alloc] init];
[self presentViewController:v animated:YES completion:^{}];
});
}
{
[super viewDidAppear:animated];
[self presentViewController:[[YourViewController alloc] init] animated:YES completion:NULL];
}
或者:
- (void)viewDidLoad
{
[super viewDidLoad];
dispatch_async(dispatch_get_main_queue(), ^{
YourViewController *v = [[YourViewController alloc] init];
[self presentViewController:v animated:YES completion:^{}];
});
}
本文介绍了在iOS应用开发中如何正确地展示视图控制器,包括在`viewDidAppear`及`viewDidLoad`方法中调用`presentViewController`的两种方式,并通过异步调度确保界面更新在主线程中进行。
321

被折叠的 条评论
为什么被折叠?



