还是老方法,直接创建tableviewController,省去一些代理的设置,直接讲解内容
不明白省略那些参考上一篇微博:
http://blog.youkuaiyun.com/lee727n/article/details/72582906
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return 50;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"reuseIdentifier"];
if (!cell) {
cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"reuseIdentifier"];
}
cell.textLabel.text = @"标题";
cell.detailTextLabel.text = @"详细内容";
cell.imageView.image = [UIImage imageNamed:@"abc"];
return cell;
}
4种cell的样子如下
UITableViewCellStyleDefault
// Simple cell with text label and optional image view (behavior of UITableViewCell in iPhoneOS 2.x)
UITableViewCellStyleValue1
// Left aligned label on left and right aligned label on right with blue text (Used in Settings)
UITableViewCellStyleValue2
// Right aligned label on left with blue text and left aligned label on right (Used in Phone/Contacts)
UITableViewCellStyleSubtitle
// Left aligned label on top and left aligned label on bottom with gray text (Used in iPod).