我想知道是否有人知道獲取UITableView的最佳方式,我們在左邊有圖像,圖像隨UIActivity指標逐漸出現,而不是不在那裏,突然出現。我看到,在幾個應用程序,並想知道如何做到這一點。Objective-C:獲取UITableView中圖像的UIActivity指標
1
A
回答
3
我沒有這個做我自己,但我的想法是創建一個處理呈現,而圖像加載UIActivity指示我自己的UIView子類。然後將該視圖的實例添加到您的表格單元格中,而不是普通的UIImageViews。
更新: OK,就像我之前說的,我沒有這樣做我自己。下面只是輸入到瀏覽器中,我不知道你是否會遇到與線程的任何問題,但它應該給你一個想法,如何處理這個:
@interface IndicatorImageView : UIView {
UIImageView *imageView;
UIActivityIndicatorView *indicator;
NSString *imageName;
NSURL *imageURL;
}
@property (nonatomic, copy) NSString *imageName;
@property (nonatomic, retain) NSURL* imageURL;
@end
@implementation IndicatorImageView
@synthesize imageName;
@synthesize imageURL;
- (id)initWithFrame:(CGRect)frame {
if (self = [super initWithFrame:frame]) {
imageView = [[UIImageView alloc] initWithFrame:self.bounds];
[self addSubview:imageView];
indicator = [[UIActivityIndicatorView alloc] initWithFrame:self.bounds];
[self addSubview:indicator];
}
return self;
}
- (void)setImageName:(NSString *)anImageName {
if (imageName == anImageName) {
return;
}
[imageName release];
imageName = [anImageName copy];
// optionally remove the old image while we're updating
//imageView.image = nil;
[indicator startAnimating];
[self performSelectorInBackground:@selector(updateImageViewUsingImageName) withObject:nil];
}
- (void)setImageURL:(NSURL *)anImageURL {
if (imageURL == anImageURL) {
return;
}
[imageURL release];
imageURL = [anImageURL copy];
// optionally remove the old image while we're updating
//imageView.image = nil;
[indicator startAnimating];
[self performSelectorInBackground:@selector(updateImageViewUsingImageURL) withObject:nil];
}
- (void)updateImageViewUsingImageName {
NSAutoreleasepool *pool = [[NSAutoreleasePool alloc] init];
imageView.image = [UIImage imageNamed:imageName];
[indicator performSelectorOnMainThread:@selector(stopAnimating) withObject:nil];
[pool release];
}
- (void)updateImageViewUsingImageURL {
NSAutoreleasepool *pool = [[NSAutoreleasePool alloc] init];
NSData *imageData = [NSData dataWithContentsOfURL:imageURL];
imageView.image = [UIImage imageWithData:imageData];
[indicator performSelectorOnMainThread:@selector(stopAnimating) withObject:nil];
[pool release];
}
@end
當您設置imageName
屬性,圖像將在後臺加載,而UIActivityIndicatorView
正在進行動畫處理。一旦圖像加載並設置在UIImageView
上,我們停止動畫活動指示器。
1
如果我能記得正確的話,那麼在從斯坦福講座cs193,iPhone應用程序編程,以及從Twitter帳戶加載個人資料照片時就會顯示出來。
尋找合適的演示文稿(我不記得它是哪一個),看看有關桌面視圖的筆記,然後看看演講的itunesu視頻。
1
子類UIImage並添加UIActivityIndicator作爲子視圖。爲類設置圖像源添加一些方法,並適當地啓動/停止UIActivityIndicator。
相關問題
- 1. UIActivity指標 - 加載視圖
- 2. 用作Uitableview頁腳顯示器時UIActivity指標顯示在設備中拉伸?使用UIActivity指標作爲UItableviewfooter
- 3. UIActivity不會顯示圖像?
- 4. UIActivity與自定義圖像
- 5. 獲取像素中的字體指標
- 6. 如何使用UIActivity指標與NSUrlConnection
- 7. ObjectiveC中的UITextView的自定義圖標
- 8. 在Dispatch_queue中的UITableView單元中獲取相同的圖像
- 9. UITableView爲圖像圖標添加標題
- 10. UItableview中的圖像
- 11. 在UITableView中獲取部分的標題
- 12. 如何通過將鼠標指向圖像上的特定點來獲取java中的圖像像素座標?
- 13. ObjectiveC在tableview中保存圖像
- 14. 在InterfaceBuilder中加載圖像序列-ObjectiveC
- 15. 如何在圖像地圖鼠標中獲取圖像的ID
- 16. 獲取圖像座標
- 17. XLib:獲取光標圖像
- 18. 獲取圖像座標
- 19. jQuery - 獲取圖像標題
- 20. 獲取UITableView實時座標
- 21. UITabBar選擇指標圖像沒有采取在ObjectiveC的tabBar高度的整體大小
- 22. 獲取Google地圖標記的指示
- 23. UITableView的圖像
- 24. 獲取python中圖像的指定像素數
- 25. Qt:獲取標準光標像素圖
- 26. 獲取的UITableView
- 27. iOS XML解析在UItableview中獲取圖像
- 28. WPF:從觸摸獲取指定圖像
- 29. 如何獲取圖標圖像
- 30. 從單個PNG圖像獲取圖標
我已經添加了一些代碼。 HTH – 2009-12-14 02:26:24
謝謝你your'e冠軍隊友 – Doz 2009-12-14 03:41:51
不知道如何將cell.imageView。(image?)分配給這個子類Tim – Doz 2009-12-15 00:50:00