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:
<Yes you can. for this you have to go for custom tableview cell. you can design this using separate XIB for tableview cell. May be this link will help you.
or search on google also for more examples its easy to implement.
you have set the frame of an imageview in cellforRowAtIndexPath
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];
}
You can create a custom cell. You just pick style custom for the cell type. If you are using static cells you can just insert an ImageView in the cell, drag an outlet to the controller header file and set the image in the code.
If you are using dynamic cells its best to create a new class for your cells. Set the custom class for the cell in the interface builder. Create and outlet for the imageview in the custom cell class header. Then when you instantiate cells in the tableView:cellForRowAtIndexPath
, set the cell class to the custom cell class and set its property.
There are very good tutorials for storyboards that cover dynamic and static cell tables:
Beginning Storyboards in iOS Part 1
Beginning Storyboards in iOS Part 2