Pregunta

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.

[[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.

Here is the didSelectRowAtIndexPath method:

- (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.

¿Fue útil?

Solución

Your QLPreviewController isn't pushed because [self navigationController] is nil.

You have to add a UINavigationController to your storyboard like this:

(Assuming that FirstViewController is your UITableViewController) Left to right: UITabBarController, UINavigationController, FirstViewController

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top