簡體   English   中英

如何讓TTPhotoViewController顯示UIImage?

[英]How to get TTPhotoViewController to display a UIImage?

我有一個UIImage,我想用TTPhotoViewController顯示,但TTPhotoViewController不會將UIImage作為參數。 它確實需要一個TTPhoto作為參數,所以我想知道是否有辦法將UIImage轉換為TTPhoto,或者是否有任何其他方法可以讓TTPhotoViewController顯示我的UIImage,而不是設置defaultImage,它沒有'工作得太好了。

我用一點點黑客來做:

NSString *url = [[TTURLCache sharedCache] createUniqueTemporaryURL];    
[[TTURLCache sharedCache] storeImage:baseImage forURL:url force:YES];

PEPhotoViewController *album=[[[PEPhotoViewController alloc] initWithImageURL:url] autorelease];

您需要創建一個符合TTPhotoSource協議的對象,並實現所需的方法。 然后,您需要使用符合TTPhoto協議的對象填充該數據源。

然后,您應該能夠在TTPhotoViewController上設置照片源屬性,並且Three20的魔法應該可以工作。

根據我自己的經驗,我只使用這個框架的URL到圖像並使用Three20的TTModel框架下載它們。 我不完全確定這會如何影響本地加載圖像。

您可以提供庫的本地路徑。 應該是bandle://documents:// 看一下TTCatalog示例源代碼。

只需將self.defaultImage設置為您的圖像。 它應該工作。

暫無
暫無

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

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