In the creation of Rolf! I wanted to add the paper game rule book to the game. The format of the book is PDF and I though it should be no problem. After much googling (please no Binging, That does not EVEN sound right does it?) I found that there are several ways to go. A lot of folks used a web view and let webkit do the rendering. That was ok, but things did not look like I wanted. Also I wanted to be able to print or add it to iBooks. The Document Interaction framework seemed to be a perfect fit. It was but there was a hitch.
First here is the code when the rule button is pressed:
This method displays the document preview asynchronously. The document interaction controller dismisses the document preview automatically in response to appropriate user interactions. You can also dismiss the preview programmatically using the
So over to the delegate protocol (
So you Must implement this Optional Method!
- (UIViewController *) documentInteractionControllerViewControllerForPreview: (UIDocumentInteractionController *) controller
I know, pretty intuitive huh! Here is the passage from the docs:
If you return a navigation controller from this method, the document interaction controller is pushed onto the navigation stack using the standard navigation controller animations. If you return any other type of view controller, the document interaction controller is displayed modally, in which case, the view controller you return must be capable of presenting a modal view controller.
In Rolf! I am not using a Nav controller to move between views. I did not want to give up the real-estate and wanted better control over the navigation. So I thought COOL. All views are capable of modal transitions. NO Problem. The Preview IS presented modally. Nope I was wrong. After looking through the views in the debugger, I found that several properties on the view were nil.
Long story short Modifing my code to:
Did the trick. Notice the next to the last line! That was it!