表视图
来源:互联网 发布:多益网络和37和4399 编辑:程序博客网 时间:2024/06/06 02:19
1. UITabBarController UINavigationController UIViewController
UITableView
缺少一份了坚持!
欲带王冠,必先承其重!
你放纵的每一秒,又有多少人在拼命!
你所听到的忠告,是别人走了多少个弯路,总结出来的!
2.协议<UITableViewDelegate,UITableViewDataSource>
以为是你 家的味道 兄弟干杯
3. _sectionList=@[@[@"搜索"],@[@"设置",@"状态"]];
[tabView release];
}
//有几个section
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return _sectionList.count;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
NSArray *array= _sectionList[section];
return array.count;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil];
cell.textLabel.text=_sectionList[indexPath.section][indexPath.row];
return cell;
[cell release];
}
4.获取当前工程下目录的路径
NSString *path=[[NSBundle mainBundle]pathForResource:@"font" ofType:@"plist"];
5.-(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
自定义section头部视图
.tableHeaderView 定义整个视图的头部视图
6._fonts=[[UIFont familyNames]retain] 记住一定要retain 不然的话会出野指针
7.static NSString *identifier=@"myCell";
//查询池子中是否有空闲的单元格
UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:identifier];
if (cell==Nil) {
cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
}
cell.textLabel.font=[UIFont fontWithName:_fonts[indexPath.row] size:14];
cell.textLabel.text=_fonts[indexPath.row];
单元格的重用法
8.plist文件 格式第一个为root默认 字典
9.背景透明
[UIColor clearColor]
10.高度自适应 核心代码
-(float)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString *text=[_data objectAtIndex:indexPath.row];
CGSize size=[text sizeWithFont:[UIFont systemFontOfSize:14]constrainedToSize:CGSizeMake(300, 1000)];
return size.height+20;
}
11.NSString *text=[_data objectAtIndex:indexPath.row]; 这是取得别人的值 不是重新定义的数
12.单元格复用问题
if (self.indexPath != nil) {
if (self.indexPath.section == indexPath.section && self.indexPath.row == indexPath.row) {
cell.accessoryType = UITableViewCellAccessoryCheckmark;
} else {
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
}
}
当前选用的是否等于将要显示的,是的话一样
不是的话不一样
//当前选中的事件
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
//设置辅助视图的样式
cell.accessoryType = UITableViewCellAccessoryCheckmark;
//记录当前选中单元格的索引
self.indexPath = indexPath;
}
//上一次选中的事件 处理上一次 辅助图标不消失问题
- (void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
//设置辅助视图的样式
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
}
13.UISearchBar 搜索框
14.搜索过滤
//初始化谓词的时候不能加占位符 这是bug
NSString *p=[NSString stringWithFormat:@"SELF LIKE[c]'%@*'",text];
NSPredicate *predicate=[NSPredicate predicateWithFormat:p];
self.filterData=[_fonts filteredArrayUsingPredicate:predicate];
UITableView
缺少一份了坚持!
欲带王冠,必先承其重!
你放纵的每一秒,又有多少人在拼命!
你所听到的忠告,是别人走了多少个弯路,总结出来的!
2.协议<UITableViewDelegate,UITableViewDataSource>
以为是你 家的味道 兄弟干杯
3. _sectionList=@[@[@"搜索"],@[@"设置",@"状态"]];
[tabView release];
}
//有几个section
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return _sectionList.count;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
NSArray *array= _sectionList[section];
return array.count;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil];
cell.textLabel.text=_sectionList[indexPath.section][indexPath.row];
return cell;
[cell release];
}
4.获取当前工程下目录的路径
NSString *path=[[NSBundle mainBundle]pathForResource:@"font" ofType:@"plist"];
5.-(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
自定义section头部视图
.tableHeaderView 定义整个视图的头部视图
6._fonts=[[UIFont familyNames]retain] 记住一定要retain 不然的话会出野指针
7.static NSString *identifier=@"myCell";
//查询池子中是否有空闲的单元格
UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:identifier];
if (cell==Nil) {
cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
}
cell.textLabel.font=[UIFont fontWithName:_fonts[indexPath.row] size:14];
cell.textLabel.text=_fonts[indexPath.row];
单元格的重用法
8.plist文件 格式第一个为root默认 字典
9.背景透明
[UIColor clearColor]
10.高度自适应 核心代码
-(float)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString *text=[_data objectAtIndex:indexPath.row];
CGSize size=[text sizeWithFont:[UIFont systemFontOfSize:14]constrainedToSize:CGSizeMake(300, 1000)];
return size.height+20;
}
11.NSString *text=[_data objectAtIndex:indexPath.row]; 这是取得别人的值 不是重新定义的数
12.单元格复用问题
if (self.indexPath != nil) {
if (self.indexPath.section == indexPath.section && self.indexPath.row == indexPath.row) {
cell.accessoryType = UITableViewCellAccessoryCheckmark;
} else {
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
}
}
当前选用的是否等于将要显示的,是的话一样
不是的话不一样
//当前选中的事件
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
//设置辅助视图的样式
cell.accessoryType = UITableViewCellAccessoryCheckmark;
//记录当前选中单元格的索引
self.indexPath = indexPath;
}
//上一次选中的事件 处理上一次 辅助图标不消失问题
- (void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
//设置辅助视图的样式
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
}
13.UISearchBar 搜索框
14.搜索过滤
//初始化谓词的时候不能加占位符 这是bug
NSString *p=[NSString stringWithFormat:@"SELF LIKE[c]'%@*'",text];
NSPredicate *predicate=[NSPredicate predicateWithFormat:p];
self.filterData=[_fonts filteredArrayUsingPredicate:predicate];
0 0
- 表视图
- 表视图
- 表视图
- 表视图
- Oracle创建视图、通过视图创建表
- 表、视图、实体化视图的比较
- 表和视图
- 表和视图关系
- 表视图的创建
- 由表建立视图
- 查看表视图
- 创建表维护视图
- 表视图学习
- 简易表视图
- 创建单表视图
- 表视图的学习
- 创建简单表视图
- 表视图的作用
- Windows下python环境变量配置
- apt命令
- android创建签名
- 将WebService编译成dll
- 与大二学生讨论专业学习
- 表视图
- javascript插入样式
- ElasticSearch Shard Placement Control
- 修改adb devices列表中设备串号名称
- C语言技巧
- centos开机界面的自己订制
- 定制单元格
- Booting Xen
- Cookie 和 Session