IOS7中UITableView中cell的使用 drawRect失效
来源:互联网 发布:西雅图房价 知乎 编辑:程序博客网 时间:2024/06/05 11:06
在iOS7中,使用UITableView的时候,对于cell要注意:[cell addSubview:textField] ;
这种用法不能再用了,应该使用 [cell.contentView addSubview:textField] 的方式。
UITableViewCell的定制
以前可以直接继承UITableViewCell然后drawRect 可以实现定制;
现在的UITableViewCell包含了一个scrollView,你重绘了UITableViewCell将会被这个scrollView遮住而完全没法显示,或者 drawRect 的方法里面用cell.contentView添加控件;
这种用法不能再用了,应该使用 [cell.contentView addSubview:textField] 的方式。
UITableViewCell的定制
以前可以直接继承UITableViewCell然后drawRect 可以实现定制;
现在的UITableViewCell包含了一个scrollView,你重绘了UITableViewCell将会被这个scrollView遮住而完全没法显示,或者 drawRect 的方法里面用cell.contentView添加控件;
【解决方案]:(ARC文件)
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{static NSString *identify = @"UITableViewCell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identify]; if(cell==nil) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identify]; } UIView * subview = [[UIView alloc] init]; subview.userInteractionEnabled = NO; subview.backgroundColor = [UIColor clearColor]; // 设为透明 subview.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; [cell.contentView addSubview:subview];// cell.contentView是个readonly属性.return cell;}
0 0
- IOS7中UITableView中cell的使用 drawRect失效
- iOS7中UITableView中cell的使用
- iOS7中UITableView中cell的使用
- iOS7中UITableView中cell的使用
- iOS7中UITableView中cell的使用
- iOS7中UITableView中cell的使用
- iOS7中UITableView中cell的使用
- iOS7中UITableView中cell的使用
- iOS7中UITableView中cell的使用
- [iOS7]IOS7中UITableView的变化
- iOS7中UITableView的变化
- IOS7中UITableView的变化
- UITableView中Cell使用标识符重用机制
- IOS7中 改变cell的宽度
- UITableView中刷新Cell
- 【OC】IOS7中UITableView的变化
- ios UITableView中Cell的重用机制
- UITableView中Cell的重用机制
- tomcat访问日志浅析
- 设计模式学习(五)——单例模式
- 习近平:全力搜救 不放弃拯救生命努力 李克强揪心失联飞机乘客
- 让eclipse完全支持HTML/JS/CSS智能提示
- CGAffineTransform相关函数
- IOS7中UITableView中cell的使用 drawRect失效
- android开发的第一次卡住。。。(…
- 又一次卡住的程序,被我摆平了。。…
- 玩,是最佳驱动力~
- 学习学习。
- ListView的学习
- 弱弱的进度条
- 所谓download。。。
- 索引列选择错误造成的性能恶化情景