我在iOS 7.1中使用UIDocumentInteractionController,它的性能非常糟糕。UIDocumentInteractionController真的很慢
我在UICollectionViewController中使用它來查看集合視圖中的文檔。
按集合視圖中的項目時,大概需要大約6(是,那是六)秒出現。從用戶體驗角度來看,他們在屏幕出現之前再次按了幾次屏幕,因爲屏幕需要這麼長時間。
我使用的是自iOS 6以來的相同代碼,但現在看起來特別糟糕。如果有人對我如何加快速度有任何想法,那將不勝感激。
從本質上講,我有我的頭文件如下:
interface MyViewController : UICollectionViewController <UIDocumentInteractionControllerDelegate>
{
UIDocumentInteractionController *docController;
}
@end
,並在實施中,我只是在做以下操作:
在viewDidLoad中(最近搬到了這裏,看它是否提高的東西):
docController = [[UIDocumentInteractionController alloc] init];
docController.delegate = self;
然後在的CollectionView:didSelectItemAtIndexPath:我這樣做:
NSURL *fileURL = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:document.Link ofType:@"" ]];
[docController setURL:fileURL];
PresentationViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"DocumentCell" forIndexPath:indexPath];
CGRect rect1 = cell.frame;
bool didShow = [docController presentOptionsMenuFromRect:rect1 inView:collectionView animated:YES];
其中文檔只是一個包含URL字符串的類。
讓我知道你是否需要任何進一步的細節。
在此先感謝任何人可以提供的幫助。
- 更新: 一些NSLogs後,我注意到,這是絕對的下面一行是很慢:
bool didShow = [docController presentOptionsMenuFromRect:rect1 inView:collectionView animated:YES];
你能對此做些什麼嗎?我似乎有這個問題? – GenieWanted
不,不幸的不是。我正考慮在這一點上使用Apple的2張門票中的一張。這真是令人沮喪。如果我設法解決任何問題,我會發布。 – Darren
我注意到,在我的情況下,它以十六進制轉儲方式將整個文件的內容寫入控制檯日誌「提供的未知活動項目」。這可能會增加延遲,但我不知道如何避免這種情況。 – fishinear