消除关闭视图控制器和呈现新视图控制器之间的延迟
Posted
技术标签:
【中文标题】消除关闭视图控制器和呈现新视图控制器之间的延迟【英文标题】:Remove delay between dismissing viewcontroller and presenting new viewcontroller 【发布时间】:2016-06-26 07:11:05 【问题描述】:我已经成功地关闭了一个视图控制器并展示了一个新的视图控制器,但是新的视图控制器会在一点延迟后出现。如何消除这种延迟?我当前的代码是:
UIViewController * vcb=self.presentingViewController;
[self dismissViewControllerAnimated:YES completion:^
UIStoryboard * storyBoard=[UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]];
ContactsViewController * VC=[storyBoard instantiateViewControllerWithIdentifier:@"contactsView"];
[vcb presentViewController:VC animated:YES completion:nil];
];
【问题讨论】:
你可以在主线程中使用dispatch_async吗 【参考方案1】:你必须指出不需要动画过渡。将您的代码更改为...
UIViewController * vcb=self.presentingViewController;
[self dismissViewControllerAnimated:YES completion:^
UIStoryboard * storyBoard=[UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]];
ContactsViewController * VC=[storyBoard instantiateViewControllerWithIdentifier:@"contactsView"];
[vcb presentViewController:VC animated:NO completion:nil];
];
如果你需要酒泥延迟试试这个...
UIViewController * vcb=self.presentingViewController;
[self dismissViewControllerAnimated:NO completion:^
UIStoryboard * storyBoard=[UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]];
ContactsViewController * VC=[storyBoard instantiateViewControllerWithIdentifier:@"contactsView"];
[vcb presentViewController:VC animated:NO completion:nil];
];
【讨论】:
以上是关于消除关闭视图控制器和呈现新视图控制器之间的延迟的主要内容,如果未能解决你的问题,请参考以下文章