UITableView-01基本使用
UITableView-02模型优化
UITableView-03复杂的Plist解析
-
tableViewCell的样式(
default, subtitle,value1,value2)
UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:nil]; -
tableViewCell常见属性
设置右边指示标-
accessoryView- 附件视图(任意的UIView)
cell.accessoryView = [[UISwitch alloc]init]; -
accessoryType- 附件样式(UITableViewCellAccessoryType)
cell.accessoryType = UITableViewCellAccessoryCheckmark;
设置选择cell
-
selectionStyle- 选中cell的样式(UITableViewCellSelectionStyle) -
selectedBackgroundView- 选中cell的背景View
设置背景
-
backgroundColor- 背景颜色 -
backgroundView- 背景视图
如:cell.backgroundView =[[UIImageView alloc]initWithImage:[UIImage imageNamed:@"XX"]];
-
cell的contentView的一些概述
- cell的
imageView,textLabel,detailTextLabel都是放在contentView上面.这样设计有什么好处?
举例: 往左滑动cell,显示删除按钮.
因为,图片+文本都在contentView上面,只需要移动contentView就能实现"图片,文本内容"的一起移动. - 证明"图片,文本"都是在
contentView上面.
-
contentView 和 imageview.superview打印的是同一个地址. - 打印contentView 的子对象
NSLog(@"%@",cell.contentView.subviews);
contentView是懒加载.
如何用字符串方式,输出double类型的属性?
@property (nonatomic, assign)double price;
//wine.money 是字符串类型, 需转换为double类型
wine.price = wine.money.doubleValue;
//字符串方式输出,保留2位小数点
cell.detailTextLabel.text = [NSString stringWithFormat:@"价格:%0.2f",wineTest.price];
UITableViewStylePlain和UITableViewStyleGrouped区别?







