Question

NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle </Users/quantum/Library/Application Support/iPhone Simulator/6.1/Applications/19503C82-22E2-4787-A4F5-8D83EDD5D58B/foo.app> (loaded)' with name '_UIDocumentActivityViewController''

I'm creating a QLPreviewController, presenting it to show a PDF. I then tap the share button. It crashes.

I downloaded Apple's Document Interaction example project. I put my PDF fetching class into there, fetched a PDF, display it.. and it works. No crash on the share button. Both are for targets 6.1. I tried setting Apple's code to target iPad only like my project. Their code works, mine doesn't, and I'm baffled. From the error message it sounds like a bug in the SDK but I can't pinpoint it.

Have you seen this before?

    QLPreviewController *previewController = [[QLPreviewController alloc] init];

    [previewController setDataSource:self];

    [previewController setDelegate:self];

    [self presentViewController:previewController animated:YES completion:^{}];



#pragma mark QLPreviewControllerDataSource

- (NSInteger) numberOfPreviewItemsInPreviewController:(QLPreviewController *)controller {

    return 1;
}

- (id <QLPreviewItem>)previewController:(QLPreviewController *)controller previewItemAtIndex:(NSInteger)index {
    return [NSURL fileURLWithPath:self.pdfPath];
}

I tried removing the reference to the framework, deleting derived data, cleaning the project, readding the QuickLook framework. I did show in Finder in both Apple's project & mine & they have the same path.

And same thing occurs when I use a UIDocumentInteractionController. That little overlay with the email/print etc options is not loading in my project.

Was it helpful?

Solution

Apple support provided me with the answer. I had over ridden an init method in a category and this screwed up the class initialization. Moral: don't override init in a category method.

OTHER TIPS

just try for initwithnib

QLPreviewController *previewController = [[QLPreviewController alloc] initWithNib: (QLPreviewController) bundle : nil];

hopefully it works.

if you have used NavigationController then use:

QLPreviewController *previewController = [[QLPreviewController alloc] init];

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

else

QLPreviewController *previewController = [[QLPreviewController alloc] init];

[self presentModalViewController:previewController animated:YES];

According to Apple's documentation QL generators should not have NIB files as resources.

Although a Quick Look generator does not (and should not) have nib files as resources, you can add other resources if necessary.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top