属性名称 | 作用 |
---|---|
separatorStyle | 分隔线样式 |
separatorColor | 分隔线颜色 |
属性名称 | 作用 |
---|---|
allowsSelection | 允许选中 |
allowsMultipleSelection | 允许多选 |
属性名称 | 作用 |
---|---|
indexPathsForSelectedRows | 当前选中行数 |
indexPathsForVisibleRows | 当前可见行数 |
属性名称 | 作用 |
---|---|
backgroundView | 背景视图 |
selectedBackgroundView | 选中时的背景视图 |
属性名称 | 作用 |
---|---|
UITableViewCellSelectionStyleNone | 没有颜色 |
UITableViewCellSelectionStyleBlue | 蓝色(默认) |
UITableViewCellSelectionStyleGray | 灰色 |
@interface ViewController ()<UITableViewDataSource>
self.tableView.dataSource = self;
//返回有多少组
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
return 2;
}
//返回有多少行,section 组的索引
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return 10;
}
//返回每一组的每一行显示什么内容
- (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
//创建UITableViewCell
UITableViewCell *tableViewCell = [[UITableViewCell alloc]init];
return tableViewCell;
}
Paste_Image.png
Paste_Image.png
UITableView *haha = [UITableView alloc]initWithFrame:<#(CGRect)#> style:(UITableViewStyle)];
Paste_Image.png
typedef NS_ENUM(NSInteger, UITableViewCellStyle) {
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).
}; // available in iPhone OS 3.0
满足不了需求,就需要自定义样式。