UITableView中textLabel和detailTextLabel的使用
2014-09-03 14:46
267 查看
以前在使用UITableView的时候, 总是在cell上自己加label, 遇到cell的accessoryType不同的时候, 需要自己调整label的大小和位置. 后来发现UITableViewCell中有textLabel和detailTextLabel可以使用, 系统配置好了大小位置, 可以根据cell的不同type和大小自动调整.
textLabel就是放置在cell左边的Label, detailTextLabel就是放置在cell右边的Label, 使用的时候需要把cell的style设为UITableViewCellStyleValue1.
代码如下:
UITableViewCell *cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1reuseIdentifier:@"cell"] autorelease];
[cell.textLabel setText:@"选项"];
[cell.detailTextLabel setTextColor:[UIColor colorWithWhite:0.52 alpha:1.0]];
[cell.detailTextLabel setText:@"详细内容"];
同时UITableViewCell中还有imageView等可以直接使用, 需要进一步研究使用.
textLabel就是放置在cell左边的Label, detailTextLabel就是放置在cell右边的Label, 使用的时候需要把cell的style设为UITableViewCellStyleValue1.
代码如下:
UITableViewCell *cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1reuseIdentifier:@"cell"] autorelease];
[cell.textLabel setText:@"选项"];
[cell.detailTextLabel setTextColor:[UIColor colorWithWhite:0.52 alpha:1.0]];
[cell.detailTextLabel setText:@"详细内容"];
同时UITableViewCell中还有imageView等可以直接使用, 需要进一步研究使用.
相关文章推荐
- UITableView中textLabel和detailTextLabel的使用
- UITableView中textLabel和detailTextLabel的使用
- UITableView: textLabel,detailTextLabel
- ios8 tableview detailtextlabel不显示内容 备注
- 调整系统tableViewCell的默认控件Imageview、textLable、detailTextLabel的frame
- 2016-02-23 控件之label textview 混合使用
- UITableView不能显示detailtext
- 调整系统tableViewCell的默认控件Imageview、textLable、detailTextLabel的frame
- iOS开发小记:iOS富文本框架DTCoreText在UITableView上的使用
- Scott Mitchell 的ASP.NET 2.0数据操作教程之十:使用 GridView 和DetailView实现的主/从报表
- Android下Button/TextView/EditText/Menu的使用
- Android基础教程(一)之------更改与显示文字标签TextView标签的使用
- AutoCompleteTextView,Spinner和ListView这几个控件的使用
- Android AutoCompleteTextView,Spinner和ListView的使用
- UITableView实例教程:创建Table View的detail view
- android的TextView使用Html(图片显示)格式。。。。。。
- AutoCompleteTextView的使用
- DropDownList的动态加载,detailview使用以及FileUpload的上传
- 使用linq2sql 的DetailView 如何保存多对多关系
- Scott Mitchell 的ASP.NET 2.0数据教程之十:使用GridView 和DetailView实现的主/从报表