According to the QLPreviewItem Protocol Reference for iOS:
“If the item is not available for preview, this property’s getter method should return nil. In this case, the Quick Look preview controller displays a ‘loading’ view.”
If you return nil for the previewItemURL as suggested the app is terminated with an exception.
This bug is filed as rdar://14216503 and on OpenRadar.
Steps to Reproduce
- Run the provided sample app on iOS 6 or iOS 7 simulator
- Push the Button
The preview controller should appear and display a spinning activity indicator.
Immediately after appearing the preview controller throws an exception which differs by iOS version:
iOS 6: ‘setObjectForKey: key cannot be nil’
iOS 7: ‘-[NSURL initFileURLWithPath:]: nil string parameter’
The same code worked without issue on iOS 5.
Sample Code: QuickLookBug project in our Radar Samples GitHub repository.
Categories: Bug Reports