Image on top of Cell

前端 未结 4 938
挽巷
挽巷 2021-01-22 13:16

Can i put an image in the top of an TableViewCell instead of putting it on the left side ? I used this to put it in the cell:

Code:

<
4条回答
  •  佛祖请我去吃肉
    2021-01-22 13:43

    For asynchronous image downloading and showing on table use this: go to https://github.com/enormego/EGOImageLoading and download the classes. then in your .h file:

    @class EGOImageView;
    
     EGOImageView *imageIconView;    // object for caching the images
    

    and in .m file

    #import "EGOImageView.h"
    #import "EGOCache.h"
    
    -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
     {
     UITableViewCell * cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"Cell"];
    
    imageIconView=[[EGOImageView alloc] initWithPlaceholderImage:[UIImage imageNamed:@"icon72x72.png"]];
    [self setFlickrPhoto:[NSString stringWithFormat:@"yourimageurl"];
    imageIconView.frame=CGRectMake(0, 0, 120, 100);
    [cell addSubview:imageIconView];
    return cell;
    }
    
    - (void)setFlickrPhoto:(NSString*)flickrPhoto
    {
    
    imageIconView.imageURL = [NSURL URLWithString:flickrPhoto];
    
    }
    

提交回复
热议问题