简体   繁体   English

pushViewController似乎无法与Storyboard和QLPreviewController一起使用

[英]pushViewController doesn't seem to work with storyboard and QLPreviewController

When trying to implement a dynamic table (using code) with a storyboard tableviewcontroller, the detail view fails to get pushed when the following code is executed. 尝试通过情节提要tableviewcontroller实现动态表(使用代码)时,执行以下代码时,详细视图无法推送。

[[self navigationController] pushViewController:previewController animated:YES];

No errors are thrown. 没有引发任何错误。 No clues whatsoever are given, except that the selected table cell gets highlighted blue and stays that way. 没有提供任何线索,只是所选表格单元格突出显示为蓝色并保持这种状态。 The issue is prevalent when using storyboards, but not when using xibs. 使用情节提要板时此问题很普遍,但使用xibs时则不然。

Here is the didSelectRowAtIndexPath method: 这是didSelectRowAtIndexPath方法:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    QLPreviewController *previewController = [[QLPreviewController alloc] init];
    previewController.dataSource = self;
    previewController.delegate = self;

    // start previewing the document at the current section index
    previewController.currentPreviewItemIndex = indexPath.row;

    [[self navigationController] pushViewController:previewController animated:YES];
    [previewController release];
}

Here is a link to a sample project with the issue . 这是带有问题的示例项目的链接。

Your QLPreviewController isn't pushed because [self navigationController] is nil. 您的QLPreviewController未被推送,因为[self navigationController]为零。

You have to add a UINavigationController to your storyboard like this: 您必须像这样将UINavigationController添加到故事板:

(Assuming that FirstViewController is your UITableViewController) (假设FirstViewController是您的UITableViewController) Left to right: UITabBarController, UINavigationController, FirstViewController 从左到右:UITabBarController,UINavigationController,FirstViewController

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM