美文网首页
UITableViewCell

UITableViewCell

作者: 英雄出少年 | 来源:发表于2019-04-16 21:41 被阅读0次

UIAlertView 和 UITableView局部刷新

注意点:获取某一行的时候使用 Tag

DraggedImage.png

UITableView索引方法

- (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView { //获取所有数组的 title属性 return [self.tgCarGroups valueForKeyPath:@"title"]; }

固定UITextView的宽度

DraggedImage-1.png

tableView开启多选状态

self.tableView.allowsMultipleSelectionDuringEditing = YES;

Cell获取的几种方式

1.利用系统自带的alloc
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:ID];

2.通过xib自定义Cell,注意重用问题不要忘了设置界面的重用标识,否则会带来很大的性能问题

DraggedImage-2.png DraggedImage-3.png

3.通过代码自定义cell(利用系统自带 或者 自己定义)

1、需要在初始化方法里添加子控件
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{...添加子控件}
2、在设置数据 或者 layoutSubviews方法里都可以布局子控件
3、在控制器中使用自定义的cell

DraggedImage-4.png

4.在Stroyboard中拖UITableView控件,添加一个cell绑定标识,不用判断cell是否为空,自动布局

DraggedImage-5.png

MVC的理解

DraggedImage-6.png

UITableView左滑进入编辑状态

实现 - (NSArray *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath 这个方法就可以进入到编辑状态
(img)

获取选中行的索引
NSArray *arrayIndexPaths = [self.tableView indexPathsForSelectedRows];

注册需要注意的地方:
注册优先级高于storyboard,这里加载的storyboard

相关文章

网友评论

      本文标题:UITableViewCell

      本文链接:https://www.haomeiwen.com/subject/yqaiwqtx.html