如何在基于分割视图的 iPad 应用程序中显示文档的快速查看

发布于 2024-11-16 22:16:20 字数 635 浏览 3 评论 0原文

我必须在基于 splitview 的应用程序的详细视图中显示文档的快速查看。在主视图中,我有一个 UITableView,其中包含我的应用程序的 Document 文件夹中的所有文件的列表。
我尝试在 DetailViewController 中使用 QLPreviewController,以这种方式:

QLPreviewController *previewController = [[QLPreviewController alloc] init];
previewController.dataSource = self;
previewController.delegate = self;
previewController.currentPreviewItemIndex = ...;
[[self navigationController] pushViewController:previewController animated:YES];
[previewController release];

我能够看到预览文档的,但我不再看到详细视图顶部的工具栏,并且在纵向模式下我永远卡住了,因为我无法在主视图中看到文件列表。
我还尝试使 DetailViewController 成为 QLPreviewController 的子类,但没有成功。

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 release];

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

烟酒忠诚 2024-11-23 22:16:20

我认为,根据您的描述,我认为您不需要将previewController推入[self navigationController],而是将previewController设置为UISplitViewController的详细视图。

可以像这样完成

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

如果您想让预览控制器出现导航栏,您可以用 UINavigationController 包装预览控制器,然后将其设置为 UISplitViewController 中的详细视图,如下所示

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

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

雅心素梦 2024-11-23 22:16:20

尝试

[self presentModalViewController:preview animated:YES]; 

代替

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

Try

[self presentModalViewController:preview animated:YES]; 

instead of

[[self navigationController] pushViewController:previewController animated:YES];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文