2014-09-25 43 views
0

我想查詢圖像在我的UITableview,但我在嘗試配置單元時遇到問題。查詢圖像到UITableView

+0

您需要在主線程上重新加載表,而不是後臺線程。 – rmaddy 2014-09-25 04:53:06

回答

0

創建UITableViewCell的子類並向其添加UIImageView屬性。下面是你的頭文件是什麼樣子的例子:

#import <UIKit/UIKit.h> 

@interface CustomTableViewCell : UITableViewCell 

@property (nonatomic, weak) IBOutlet UIImageView *icon; 

//@property (nonatomic, strong) UIImageView *icon; //Only if you're not using an XIB/storyboard 

@end 

然後,你cellForRowAtIndexPath:功能將類似於這樣:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    static NSString *[email protected]"cellimage"; 
    CustomTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath]; 

    //the following assumes that your self.images array contains UIImages 
    cell.icon.image = [self.images objectAtIndex:indexPath.row]; 

    return cell; 
} 

此外,一定要打電話reloadData主線程

+0

但是我應該把什麼放在UIImage * yourImage – 2014-09-25 04:59:22

+0

無論你的圖像是什麼。你如何從你的'PFObject'獲得你的圖像? – rebello95 2014-09-25 05:00:24

+0

可以在你的代碼中加個例子 – 2014-09-25 05:01:32