【问题标题】:iOS - call the method : [self.navigationController pushViewController: animated:], the screen get whole blackiOS - 调用方法:[self.navigationController pushViewController: animated:],屏幕全黑
【发布时间】:2016-05-10 14:15:46
【问题描述】:

我想通过在表格视图中选择一行来推送 SecViewController。我正在使用 Storyboard 来实现它。这是我的代码:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

SecViewController *sec = [[SecViewController alloc] init];
[self.navigationController pushViewController:sec animated:NO];

}

这是我的故事板:

但是当我运行这个应用程序时: 出现这种情况:

为什么会这样?

【问题讨论】:

  • 您正在创建 SecViewController 的新实例,但代码不知道要使用什么“nib”。查看@Balaji 的答案。

标签: ios objective-c uitableview storyboard pushviewcontroller


【解决方案1】:

修改你的代码如下:

SecViewController *sec = [self.storyboard instantiateViewControllerWithIdentifier:@"viewControllerIdentifier"];

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

viewControllerIdentifier 更改为该视图控制器的情节提要标识符 ..

希望对你有帮助..

【讨论】:

  • 是的!这是使用storyboard设计布局的方式。如果只使用代码布局我的方式也是可行的。
【解决方案2】:

请检查:

  • 您的按钮必须添加约束,或正确设置大小和原点
  • 您的按钮已添加到正确的超级视图中
  • 如果您在该 viewController 中有一个视图 :)(请尝试更改背景颜色,不确定)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-09-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-09-19
    相关资源
    最近更新 更多