1、修改根试图
点击view controller scene下边,选中scene,按del键即可删除;
从控件库中拖拽一个Tab View Controller到设计界面;
然后右边的属性检查器中,选中View Controller---> is Initial View Controller复选框;
如下图:




2、设置单元格

设置类

设置可重用单元格标示符

3、设置自定义单元格类CustomCell


创建之后,如下:

设置单元格的类(绑定)

单元格中的label image 输出关联到 CustomCell.h中:

ViewController.m中,引入头文件:
#import "ViewController.h"
#import "CustomCell.h"
#define cellIdentifier @"CellIdentifier"
@interface ViewController ()
@property (nonatomic, strong) NSArray *listTeams;
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
NSBundle *bundle = [NSBundle mainBundle];
NSString *plistPath = [bundle pathForResource:@"team"
ofType:@"plist"];
//获取属性列表文件中的全部数据
self.listTeams = [[NSArray alloc] initWithContentsOfFile:plistPath];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#pragma mark --UITableViewDataSource 协议方法
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [self.listTeams count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
CustomCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier forIndexPath:indexPath];
NSUInteger row = [indexPath row];
NSDictionary *rowDict = self.listTeams[row];
cell.myLabel.text = rowDict[@"name"];
NSString *imageFile = rowDict[@"image"];
NSString *imagePath = [[NSString alloc] initWithFormat:@"%@.png", imageFile];
cell.myImageView.image = [UIImage imageNamed:imagePath];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
return cell;
}@end
参考:《IOS开发指南》
659

被折叠的 条评论
为什么被折叠?



