------------------
tableVeiw控件的代理(dataSource) 与delegate属性类似 只是名称不一样
self.dataSource = self;
设置tableView控件的dataSource 为viewController
设置tableView的样式为 group / plain (group有分组效果)
1、tableView上下左右 20 0 0 0加约束
2、节组数 行数 单元格 节组头文字 节组底文字
Sections(tableView中的节组数 numberOfSectionsInTableView)、 Rows(节组中的行数 numberOfRowsInSection)、
cell(tableView的单元 cellForRowAtIndexPath) 、
titleForHeaderInSection (节组头部的文字)、titleForFooterInSection (节组底部的问题)
------------
tableView单组 lol数据展示
1、做Hero数据模型
2、heros数据懒加载
3、tableView懒加载 (新建tableView样式为plain 设置代理datasource )
4、实现sourceData代理协议方法
5、指定tableView.delegate = self 设置每一行不同高度 (heightForRowAtIndexPath)
(方法2:不用delegate 那么可以 tableView.rowHeight = 44//默认的 效率高 但是每一行只能固定都是这么多了)
6、Cell右边的箭头设置
(
1设置 tableView.delegate = self
2cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; 会触发行的选中
cell.accessoryView不会触发行的选中
)
7、UITableView点击哪一行
(
1设置tableView.delegate = self
2didSelectRowAtIndexPath (取消选中某一行didDeSelectRowAtIndexPath 很少用到 先点击第二行 再点击第三行 这时候执行了取消选中第2行)
)
8、点击小箭头执行的方法
accessoryButtonTappedForRowAtInDexPath;
9、点击accessoryButton类型控件等
accessoryButtonTappedForRowWithIndexPath; //只能监听accessoryButton类型控件 其他类型控件需要单独添加监听方法
10、tableView根据 可重复使用cell标记取出 取出cell , 如果没有,那么新建cell ,并cell自己设置可重用标记
11、设置cell的背景图片 无需指定view大小 backgroundView无需指定 自动根据图片大小来显示
UIImage *bgImage = [UIImage imageNamed:@"img_01"];
cell.backgroundView = [[UIImageView alloc] initWithImage:bgImage];
12、tabelView设置分割线 分割线颜色
tableView.seperatorStyle = UITableViewCellSeperatorStyleSingleLine;
tableView.seperatorColoer = [UIColor redColor];
13、设置tableView最顶部和最底部View
self.tableView.tableHeaderView
self.tableView.tableFooterView

View Code
------------
tableView-汽车品牌logo 右侧a-z
步骤:
1、导入Log分类文件夹
2、重写carGroup 和Car类的description方法 改变输出格式 NSLog(@"%@",carGroup);
3、设置tableView.datasource 实现UIDataSourceDelegate协议方法
4、右侧 节点索引列表 sectionIndexTitlesForTableView
5、使用KVC的方式 设置右侧索引列表
遍历所有房间Lists
遍历所有人员Lists
-------
KVC
// 如果取值的对象是一个数组,同样返回一个数组 数组中包含dictinary取值方法
return [self.carGroups valueForKeyPath:@"title"];
// NSArray *arr = [self.carGroups valueForKeyPath:@"cars.name"] //数组数组中dictionary中所有 cars键下的name键对应的值
// [self setValuesForKeysWithDictionary:dict];
// [self setValue:dict[@"title"] forKey:@"title"];
------
tableView - 添加删除按钮出现
tableView代码创建,并实现协议
1、实现向左滑动删除出现 commitStyleEditing
2、开启删除模式 左侧出现红色删除红圈圈(点击后等同于向左滑动删除出现动作) self.tableView.editting = YES;
3、删除模式下 左侧出现添加按钮红圈圈
2 +按钮出现需要实现方法 并设置delegate self.tableView.delegate = self;
tableVieweditingStyleForRowAtIndexPath
红圈圈,绿圈圈
- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath
{
// if (indexPath.row % 2) {
// return UITableViewCellEditingStyleInsert;
// } else {
// return UITableViewCellEditingStyleDelete;
// }
return UITableViewCellEditingStyleInsert;
}
3、
commitEditingStyle 提交添加操作后执行
[self.dataList removeObjectAtIndex:indexPath.row];
[self.tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationMiddle];
[self.tableView insertRowsAtIndexPaths:@[path] withRowAnimation:UITableViewRowAnimationMiddle];
代码:

自定义代理delegate
写 控制器<***delegate>遵守协议是为了方便敲代码 有提示 遵守了协议就等同于写了这个方法协议方法的声明 需要写出方法的实现部分
1、定义appView的delegatez协议
@class HMAppInfo, HMAppView;
// 1. 协议名以类名开始+Delegate
@protocol HMAppViewDelegate <NSObject>
@optional
// 2. 协议方法,以类名开始(没有类前缀),第一个参数是自己
// 只是定义方法名,不做具体实现
- (void)appViewDidClickDownloadButton:(HMAppView *)appView;
@end
// 3. 定义代理属性,遵守了HMAppViewDelegate协议的任意一个对象,都可以成为代理
@property (nonatomic, weak) id<HMAppViewDelegate> delegate;
2、设置appView的代理为控制器
appView.delegate = self;
3、判断代理时候实现了该代理方法 self.delegate reponseToSelector:selector(appViewDidClickDownloadButton:)
/** appView - xib里的按钮 连线监听方法 */
- (IBAction)click:(UIButton *)button
if ([self.delegate respondsToSelector:@selector(appViewDidClickDownloadButton:)]) {
// 2> 如果实现了,再通知代理去工作
[self.delegate appViewDidClickDownloadButton:self];
}
------
内存
IOS程序启动
iphone手机应用程序 栈区占据1M内存空间 mac占据的是8M
其他不重要的
数组中取出的都是id类型的 只能使用get方法 不能用 点. 语法
可变数组和不可变数组的使用
NSArray *array = @["1","2"];
_arrayList = [NSMutableArray arrayWithObjects:@"张1",@"张2",@"张3",@"张4",@"张5",@"张6",@"张7",@"张8",@"张9",@"张10",@"张11",@"张12", nil];
对象包装成数组 @[obj]