//下面介绍下cell上的文字操作
cell.textLabel.numberOfLines=2;//字数长的话可以换行
cell.textLabel.font=[UIFontsystemFontOfSize:10];//设置字号
cell.textLabel.textColor=[UIColorredColor];//设置颜色
cell.textLabel.textAlignment=NSTextAlignmentLeft;//设置对齐方式
//cell.textLabel.frame 可以设置label的坐标
//label所具有的属性cell.textLabel也是有的
//cell的几种accessoryType样式
cell.accessoryType =UITableViewCellAccessoryDisclosureIndicator;
/*
UITableViewCellAccessoryNone, // don't show any accessory view
UITableViewCellAccessoryDisclosureIndicator, // regular chevron. doesn't track
UITableViewCellAccessoryDetailDisclosureButton, // info button w/ chevron. tracks
UITableViewCellAccessoryCheckmark, // checkmark. doesn't track
UITableViewCellAccessoryDetailButton NS_ENUM_AVAILABLE_IOS(7_0) // info button. tracks
*/
//其中的button有代理
-(void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath{
NSLog(@"123");
}
可以通过
cell.accessoryView的方法自定制button 并且实现方法
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
//在这里面我们可以设置cell被选中之后的操作,比如页面跳转,或者其它动作
//取消选中状态
[tableView deselectRowAtIndexPath:indexPathanimated:YES];
}
//如果我不想指定的cell有触发事件可以这样
-(NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
//我让cell点击的时候没有反应
return nil;
}