2016-06-07 113 views
3

演示UIDocumentMenuViewController以能夠將文件加載到應用程序中。在iPhone上它可以工作,但不能在iPad上工作。使用iOS9。任何想法有什麼不對?UIDocumentMenuViewController在iPad上崩潰,但在iPhone上不崩潰

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

2016年6月7日09:45:45.256記[2994:977408]的 UICollectionViewFlowLayout的行爲不是限定,因爲:2016年6月7日 09:45:45.260記[2994 :977408]項目寬度必須小於 UICollectionView的寬度減去左側的節插入和 右側值,減去內容插入的左側和右側值。 2016年6月7日09:45:45.261記[2994:977408]相關 UICollectionViewFlowLayout實例是 < _UIAlertControllerCollectionViewFlowLayout:0x1668e6e0>,它是 附接到; 動畫= {bounds.origin =; bounds.size =; position =; }; layer =; contentOffset:{0,0}; contentSize:{0,0}>集合 視圖佈局:< _UIAlertControllerCollectionViewFlowLayout:0x1668e6e0>。 2016-06-07 09:45:45.262記住[2994:977408]在UICollectionViewFlowLayoutBreakForInvalidSizes中創建符號爲 的斷點,以在調試器中捕獲 。

我不明白爲什麼錯誤信息是指collectionView?我根本不使用collectionView。也許UIDocumentMenuViewController將它作爲內部組件?

+0

任何運氣在這裏/ – MScottWaller

+0

試試這個:http://stackoverflow.com/a/25644145/3718570 – Ptah

回答

0

我有同樣的問題。我設置了sourceView = self.view,並且必須創建一個sourceRect = theButton.frame。

3

iPad擁有約ActionSheets一些特殊的規則和他們的取消按鈕,這通常取決於你在哪裏顯示從ActionSheets,所以這是你如何解決崩潰問題:?

 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)