【问题标题】: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吗

标签: ios objective-c iphone uiviewcontroller


【解决方案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];

}];

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-11-20
    • 1970-01-01
    • 2017-07-09
    • 1970-01-01
    相关资源
    最近更新 更多