iOS - 调用方法 : [self. navigationController pushViewController : animated:], 屏幕全黑

标签 ios objective-c uitableview storyboard pushviewcontroller

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

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

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

}

这是我的 Storyboard: enter image description here

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

为什么会这样?

最佳答案

如下更改代码:

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

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

viewControllerIdentifier 更改为该 View Controller 的 Storyboard标识符..

希望对你有帮助..

关于iOS - 调用方法 : [self. navigationController pushViewController : animated:], 屏幕全黑,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37141131/

相关文章:

iphone - 确定 MPMoviez Controller 比特率

ios - OCMockito 验证和 NSError 的编译错误**

ios - 调整 UIPopoverController 的大小

arrays - 我需要使用数组将数据从 UITableViewController 传递到 UIViewController

iphone - UIGraphicsBeginImageContextWithOptions 无提示崩溃

iphone - stringByAddingPercentEscapesUsingEncoding :? 的反义词是什么?

ios - UITableViewCell.imageView 给出内存警告?

ios - 使 CollectionView 和 TableView 高度动态化

ios - 设置中的 iCloud iCon 仅在 iOS 中显示为白色

ios - XCTest 的@testable 幕后发生了什么?