开发一款ipad应用程序,开始接触ios,网上调查了很多信息,非常感谢有那么多网友的帮助。
在这里也把自己用到的总结一下,方便自己和其它网友查询。
自定义UITableViewCell的使用
1:视图中使用多个TableView,设置tag来区分。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
if(tableView.tag == 1 )
{
}
}
2:TableViewCell选中不高亮显示
cell.selectionStyle = UITableViewCellSelectionStyleNone;
cell.contentView.backgroundColor = [UIColor blackColor];
如果自定义颜色
cell.contentView.backgroundColor = [UIColor colorWithRed:0.898 green:0.898 blue:0.898 alpha:1.0];//#eeeeee
4:选中高亮背景色设置(黑色)
UIView* bgView = [[UIView alloc] init] ;
bgView.frame = CGRectMake(10, 5, 140, 30);
[bgView setBackgroundColor:[UIColor colorWithWhite:2 alpha:0.2]];
[cell setSelectedBackgroundView:bgView];
cell.selectedBackgroundView.backgroundColor = [UIColor blackColor];
[tableView selectRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] animated:NO scrollPosition:0];
NSIndexPath *ip = [NSIndexPath indexPathForRow:0 inSection:0];//获得选中的第几行
tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
UIView *v1 =[[UIView alloc]initWithFrame:CGRectMake(0, 0, 155, 1)];
v1.backgroundColor = [UIColor whiteColor];
[tableView setTableFooterView:v1];