TableView常用设置和遇到的问题

来源:互联网 发布:matlab数据预处理 编辑:程序博客网 时间:2024/04/30 22:02

UITableView的常见设置

// 分割线颜色self.tableView.separatorColor = [UIColor redColor];// 隐藏分割线self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;// tableView有数据的时候才需要分割线// 开发小技巧:快速取消分割线 self.tableView.tableFooterView = [[UIView alloc] init];

UITableViewCell的常见设置

// 取消选中的样式(常用) 让当前 cell 按下无反应cell.selectionStyle = UITableViewCellSelectionStyleNone;// 设置选中的背景色/图片/ViewUIView *selectedBackgroundView = [[UIView alloc] init];selectedBackgroundView.backgroundColor = [UIColor redColor];cell.selectedBackgroundView = selectedBackgroundView;// 设置默认的背景色cell.backgroundColor = [UIColor blueColor];// 设置默认的背景色/图片/ViewUIView *backgroundView = [[UIView alloc] init];backgroundView.backgroundColor = [UIColor greenColor];cell.backgroundView = backgroundView;// backgroundView的优先级 > backgroundColor// 设置指示器//    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;cell.accessoryView = [[UISwitch alloc] init];

与storyBoard结合使用时,错误将UIViewController当做UITableViewController来用

用法错误

原创粉丝点击