开发者

UIDocumentInteractionController not working in iPad Simulator (XCode 3.2.3)

The UIDocumentInteractionController appears to be non-functional in iPad Simulator ("iPhone Simulator" version 4.0, shipping with XCode 3.2.3, using iOS Version 3.2).

I have a simple sample code presenting a PDF preview using UIDocumentInteractionController. It works on the device. On iPad presentPreview just returns NO, the UIDocumentInteractionController's delegat开发者_Go百科e methods are not invoked.

Any hint how to make it work?


Confirming the same behaviour over here: calling - (BOOL)presentPreviewAnimated: returns NO on the simulator but works on the device. Thanks for pointing this out, I just spent two hours going over my code again and again. Got no solution so far.


I actually had this issue on iOS versions higher than iOS 4.2, even though this was a known bug back in the day.

The issue being that the UIDocumentInteractionController would act fine on the device, but in the simulator it would crash. What I discovered was that the problem went away when I managed the memory slightly differently. The difference being, autoreleasing in the DidEndPreview delegate method. Here's the core of my code :

-(void)createPDF
{
    UIDocumentInteractionController *dc;
    //....other code to generate pdf document
    dc = [[UIDocumentInteractionController interactionControllerWithURL:loadURL] retain];
    dc.delegate = self;

    [dc retain];

    [dc presentPreviewAnimated:YES];
}

//Delegate Methods
- (void)documentInteractionControllerDidEndPreview:(UIDocumentInteractionController *)controller
{
    [controller autorelease];
}

Previously I had handled simply created the document controller like a regular modal view and released it after I presented it.

NOTE : The autorelease is important, you will crash with just a regular release call.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜