实现加载图片的方式:
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
@synthesize tableIndexData;
- (void)viewDidLoad {
self.tableIndexData = [[NSArray alloc] initWithObjects:@"收件箱",@"草稿",@"已发送",@"废纸篓",@"收件箱",@"草稿",@"已发送",@"废纸篓", @"收件箱",@"草稿",@"已发送",@"废纸篓", @"收件箱",@"草稿",@"已发送",@"废纸篓", @"收件箱",@"草稿",@"已发送",@"废纸篓", nil];
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
//获取表格的数据记录数
- (NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [self.tableIndexData count];
}
//获取表格数据
- (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *tableIdentifier = @"tableIdentifier";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:tableIdentifier];
if(cell == nil)
{
cell = [[UITableViewCell alloc] initWithFrame:CGRectZero];
}
cell.textLabel.text = [self.tableIndexData objectAtIndex:[indexPath row]];
//加载图片
UIImage *img = [UIImage imageNamed:@"email"];
cell.imageView.image = img;
return cell;
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end