簡體   English   中英

在iOS中預覽保管箱文件

[英]Preview of dropbox file in iOS

我正在將Dropbox與IOS應用程序集成。 我能夠獲取選定的文件元數據。 但是在選擇文件后找不到顯示預覽的方法。 有人可以建議哪個API有用。

我正在使用的保管箱是: https : //www.dropbox.com/developers/dropins/chooser/ios

當用戶想要從保管箱中選擇文件時,將調用下面的代碼:

- (void)didPressChoose
{   
    [[DBChooser defaultChooser] openChooserForLinkType:DBChooserLinkTypePreview fromViewController:self
                                            completion:^(NSArray *results)
     {   
         if ([results count]) {
             _result = results[0];
             //After getting the result, i want to preview the file
         } else {
             _result = nil;
             [[[UIAlertView alloc] initWithTitle:@"CANCELLED" message:@"user cancelled!"
                                        delegate:nil cancelButtonTitle:@"Okay" otherButtonTitles:nil]
              show];
         }
         [[self tableView] reloadData];
     }];
}

當您要求DBChooserLinkTypePreview ,從選擇器中獲得的DBChooserResult將具有如下所示的NSURL鏈接:

https://www.dropbox.com/s/toyzur6e0m34t7v/dropbox-logos_dropbox-glyph-blue.png

此鏈接類型用於直接用戶交互,因此您可以將用戶發送到那里,如果可能的話,Dropbox將顯示帶有文件預覽的頁面。

另外,您可能想使用DBChooserLinkTypeDirect ,它為您提供了這樣的直接鏈接:

https://dl.dropboxusercontent.com/1/view/969vkzdys770277/Testing/Images/dropbox-logos_dropbox-glyph-blue.png

這是指向文件內容的直接(但臨時)鏈接。 您可以以編程方式下載文件內容(例如,請參閱如何使用目標C在iOS上本地下載和保存文件? ),然后使用該文件進行任何操作。 例如,如果它是圖像等,則可能要在UIImageView中顯示它。

此外, DBChooserResult包含一個thumbnails屬性,該屬性具有指向縮略圖的鏈接(如果所選文件是圖像或視頻),該鏈接可能同樣有用。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM