开发者

How to set diff. image in cell in table

开发者 https://www.devze.com 2022-12-13 18:51 出处:网络
How to set different icon image for each cell in the UIt开发者_如何学Cable View.In your tableview delegate:

How to set different icon image for each cell in the UIt开发者_如何学Cable View.


In your tableview delegate:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    static NSString *CellIdentifier = @"Cell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
    }
    cell.imageView.image=[someDataClass methodThatReturnsAnImage]; 
    cell.textLabel.text=[someDataClass methodThatReturnsAString]; 
    return cell;
}
0

精彩评论

暂无评论...
验证码 换一张
取 消