我的UITableView是UITableViewStylePlain风格的,这样整个TableView都会被分割线分隔开,不管有没有数据,非常丑。。。
比如下图,我只有4行数据
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ return 4; }
找了好久没有找到相关的选项,让有数据的Cell才显示分割线,没有数据的不显示。
求解一个方案。。。
self.table.tableFooterView = [[UIView alloc] init];
[tableview setTableFooterView:[[UIView alloc] initWithFrame:CGRectZero]];
将UITableView的separatorStyle属性设置为UITableViewCellSeparatorStyleNone即可,如下:
tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
UIView *v = [UIView alloc] initWithFrame:CGRectMake(0,0,320,80)]; tableview.tableFooterView = v; [v release];
tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
每个Cell下面添加一条自己写的直线
设置每个section里面的行数试试