【问题标题】:navigationController popToRootViewControllerAnimated not working in iOS 8navigationController popToRootViewControllerAnimated 在 iOS 8 中不起作用
【发布时间】:2015-07-10 06:29:31
【问题描述】:

我在 UINavigationController 中嵌入了一个登录 UIViewController,用户输入 UserID/Password 然后单击 [Login] 按钮,如下所示:

2-textfields 和一个 UIButton,当用户点击按钮时我运行代码:

    -(void)btLoginTapped:(id)sender{
[doLogin];
NSLog(@"Login Successful.")
[self.navigationController popToRootViewControllerAnimated:YES];
}

现在我在使用模拟器或 iOS 8 设备时出现问题 我将看到日志消息,但 ViewController 不会弹出,因为当我在 iOS 7 中使用模拟器/设备时,视图将正常弹出到根目录。 为什么不 [self.navigationController popToRootViewControllerAnimated:YES] 在 iOS 8+ 中工作,但它会在 iOS 7+ 中工作? 请注意,我已将 Animated 标志更改为 NO,我也尝试过: [self.navigationController popViewControllerAnimated:YES/NO] 但还是同样的问题?!​​!

感谢任何输入。谢谢。

【问题讨论】:

  • 检查我已编辑的答案。
  • 我的问题不在于 [navigationController popViewControllerAnimated:] 它有效,而仅适用于运行 iOS 8 之前的设备或模拟器。但如果我在具有 iOS 8.4 的设备或模拟器中运行 popViewController 视图不会弹出?!有人有类似问题吗?

标签: objective-c ios7 ios8 uinavigationcontroller


【解决方案1】:

试试这个

[self dismissViewControllerAnimated:YES completion:nil]; 

而不是popToRootViewControllerAnimated,如果您可以推送您的根视图控制器,那么它将起作用。 希望对您有所帮助。

【讨论】:

  • 试过了。它不仅不起作用,而且 iosSimulator iPhone4s(7.4) 也停止工作。
猜你喜欢
  • 1970-01-01
  • 2017-02-08
  • 2014-11-29
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-10-28
  • 2015-03-29
相关资源
最近更新 更多