开发者

How to show quick look of a document in a splitview based iPad app

开发者 https://www.devze.com 2023-03-14 20:18 出处:网络
I have to show quick look of a document in the detailView of a splitview based app. In the master view I have a UITableView with the list of all the files in the Document folder of my app. I\'m trying

I have to show quick look of a document in the detailView of a splitview based app. In the master view I have a UITableView with the list of all the files in the Document folder of my app.

I'm trying to use the QLPreviewController in the DetailViewController, in this way:

QLPreviewController *previewController = [[QLPreviewController alloc] init];
previewController.dataSource = self;
previewController.delegate = self;
previewController.currentPreviewItemIndex = ...;
[[self navigationController] pushViewController:previewController animated:YES];
[previewController rel开发者_运维技巧ease];

I'm able to see the preview of the document, but I don't longer see the toolbar at the top of the detail view, and in portrait mode I'm stuck forever, because I'm not able to see the file list in the master view.

I also tried to make DetailViewController subclass of QLPreviewController, but without success.


I think instead of pushing the previewController into the [self navigationController], what I believe you need to do instead, from what you described, is to set the previewController as the detail view of your UISplitViewController.

This can be done like so

[splitViewController setViewControllers:[NSArray arrayWithObjects:masterViewController, previewController, nil]];

If you want to have the navigation bar for for the previewController to appear, you can wrap the previewController with a UINavigationController before setting it as the detail view in UISplitViewController like so:

UINavigationController *wrapperNavigationController = [[[UINavigationController alloc] initWithRootViewController:previewController] autorelease];
[splitViewController setViewControllers:[NSArray arrayWithObjects:masterViewController, wrapperNavigationController, nil]];

Cheers


Try

[self presentModalViewController:preview animated:YES]; 

instead of

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

精彩评论

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

关注公众号