【问题标题】:pushViewController causing crashpushViewController 导致崩溃
【发布时间】:2013-11-11 15:02:03
【问题描述】:

我正在使用此代码推送我的下一个视图控制器,它在 IOS 7 上运行良好,现在我已将部署目标更改为 6.1。我从 tableview 单元的 didSelectRowAtIndexPath 调用此代码。当单元格仅第一次被轻敲时,它会导致崩溃,然后会变得平滑。没有崩溃日志。它在 iOS 7 上仍然可以正常工作。

UIViewController *view = [self.storyboard instantiateViewControllerWithIdentifier:@"Test"];
[self.navigationController pushViewController:view animated:YES];

我尝试设置“animated=NO”效果很好

[self.navigationController pushViewController:view animated:NO];

问题出在哪里? 另外,我在 cellForRowAtIndexPath 中设置单元格的背景颜色,在 iOS 7 中显示颜色但在 iOS 6.1 中不显示

【问题讨论】:

  • 崩溃日志在哪里?

标签: iphone uitableview uinavigationcontroller ios7 ios6.1


【解决方案1】:

改变:

UIViewController *view = [self.storyboard instantiateViewControllerWithIdentifier:@"Test"];
[self.navigationController pushViewController:view animated:YES];

与:

UIViewController *view =(UIViewController *) [self.storyboard instantiateViewControllerWithIdentifier:@"Test"];
[self.navigationController pushViewController:view animated:YES];

【讨论】:

  • @AzkaarAli 为什么不尝试使用 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender 转到详细视图,因为您正在使用情节提要?
  • 就我而言,我从每个单元格调用不同的视图控制器。如何为每个调用绘制单独的 Segue?
  • @AzkaarAli 为什么不召回同一个视图控制器,它只会改变内容?否则你可以尝试将每个单元格连接到正确的细节和我上面写的方法你可以使用这个代码: if ([[segue identifier] isEqualToString:@"detail1"]) {} else if ([[segue identifier] isEqualToString:@ "detail2"]) ...
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-01-23
  • 2020-12-02
  • 2011-01-24
  • 2015-02-23
  • 2011-04-23
相关资源
最近更新 更多