DocumentMenuViewController在iPad上

DocumentMenuViewController在iPad上

本文介绍了UIDocumentMenuViewController在iPad上崩溃,但在iPhone上不崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

呈现一个UIDocumentMenuViewController以便能够将文件加载到应用程序中.在iPhone上可以使用,但在iPad上不能使用.使用iOS9.知道有什么问题吗?

Presenting a UIDocumentMenuViewController to be able to load file into app. On iPhone it works, but not on iPad. Using iOS9. Any idea what is wrong?

dmvc = UIDocumentMenuViewController(documentTypes: ["public.data"], inMode: .Import)
dmvc!.delegate = self
dmvc!.popoverPresentationController?.sourceView = addSongButton
self.presentViewController(dmvc!, animated: true, completion: nil)

我不明白为什么错误消息引用了collectionView?我根本不使用collectionView.也许UIDocumentMenuViewController有它作为内部组件吗?

What I do not understand why error message refers collectionView? I do not use collectionView at all. Maybe UIDocumentMenuViewController has it as inner component?

推荐答案

iPad有一些有关ActionSheets及其取消按钮的特殊规则,通常取决于显示ActionSheets的位置,因此这是解决崩溃的方法问题:

iPad has some special rules about ActionSheets and their cancel buttons, It usually depends on where you are displaying the ActionSheets from, so this is how you can resolve the crashing issue:

     let importMenu = UIDocumentMenuViewController(documentTypes: [kUTTypeHTML as String ], in: .import)
    importMenu.delegate = self
    importMenu.modalPresentationStyle = .popover
    importMenu.popoverPresentationController?.sourceView = self.view
    self.present(importMenu, animated: true, completion: nil)

这篇关于UIDocumentMenuViewController在iPad上崩溃,但在iPhone上不崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-14 12:01