【发布时间】:2014-03-20 16:53:07
【问题描述】:
我在 Xcode 5 中使用故事板,我试图从 UINavigationController 中的 UITableViewController 推送到 UIViewController,但有时会出现黑屏(可能有 75% 的时间)。通过阅读其他帖子,我学会了使用instantiateViewControllerWithIdentifier: 方法在推送之前实例化我正在推送的视图控制器,所以我的代码如下所示:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[tableView deselectRowAtIndexPath:indexPath animated:YES];
if (indexPath.row < self.objects.count) {
PFObject *retrievedProduct = [self.objects objectAtIndex:indexPath.row];
Product *product = [[Product alloc] init];
// set properties for retrieved product
// (code omitted)
//load product detail page
self.detailPage = [[UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]] instantiateViewControllerWithIdentifier:@"MPDetailPageViewController"];
self.detailPage.product = product;
//Bring to detail page
[self.navigationController pushViewController:self.detailPage animated:YES];
} else if (self.paginationEnabled) {
// load more
[self loadNextPage];
}
}
在 MPDetailPageViewController 中,我在 viewDidAppear 中执行 NSLog,即使屏幕为黑色,它仍在打印。
任何建议将不胜感激。
谢谢, 蒂姆
【问题讨论】:
-
您是否在情节提要上添加了storyBoardId 标识符
-
是的,我推送的 ViewController 的 Storyboard ID 为“MPDetailPageViewController”
标签: objective-c uinavigationcontroller xcode5 xcode-storyboard