UiTableview的常用小知识汇集
2015-09-11 12:33
399 查看
1. UITableview不显示分割线
tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
2. UITableview 不显示右侧箭头
cell.accessoryType = UITableViewCellAccessoryNone;
注:其他的想修改的,自己修改后面类型
3. UITableview 选中状态
选中后处理
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
// 取消选中状态
[tableView deselectRowAtIndexPath:indexPath animated:NO];
}
选中前处理不允许出现选中状态
cell.selectionStyle = UITableViewCellSelectionStyleNone
4. 无数据不显示多余的cell行数(设置尾视图)
[chatView setTableFooterView:[[UIView alloc] initWithFrame:CGRectZero]];
5. UITableview指定刷新某行
/**
* table滚动到最后一行
*/
- (void)tableScrowToBottom
{
[_tableview scrollToRowAtIndexPath:
[NSIndexPath indexPathForRow:[dataArr count]-1 inSection:0]
atScrollPosition: UITableViewScrollPositionBottom
animated:NO];
}
6. UITableview指定显示某行
NSIndexPath *indexPath_1=[NSIndexPath indexPathForRow:arrIndex inSection:0];
NSArray *indexArray=[NSArray arrayWithObject:indexPath_1];
[_tableview reloadRowsAtIndexPaths:indexArray withRowAnimation:UITableViewRowAnimationAutomatic];
7. UITableview复用注意
在cell复用的时候前往要注意要将添加视图放在初始化里面,而不是外面,例如放在自己写的init方法里或者在if(cell == nil)里,这样当cell重新加载才不会重复添加视图到时界面视图重叠。
tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
2. UITableview 不显示右侧箭头
cell.accessoryType = UITableViewCellAccessoryNone;
注:其他的想修改的,自己修改后面类型
3. UITableview 选中状态
选中后处理
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
// 取消选中状态
[tableView deselectRowAtIndexPath:indexPath animated:NO];
}
选中前处理不允许出现选中状态
cell.selectionStyle = UITableViewCellSelectionStyleNone
4. 无数据不显示多余的cell行数(设置尾视图)
[chatView setTableFooterView:[[UIView alloc] initWithFrame:CGRectZero]];
5. UITableview指定刷新某行
/**
* table滚动到最后一行
*/
- (void)tableScrowToBottom
{
[_tableview scrollToRowAtIndexPath:
[NSIndexPath indexPathForRow:[dataArr count]-1 inSection:0]
atScrollPosition: UITableViewScrollPositionBottom
animated:NO];
}
6. UITableview指定显示某行
NSIndexPath *indexPath_1=[NSIndexPath indexPathForRow:arrIndex inSection:0];
NSArray *indexArray=[NSArray arrayWithObject:indexPath_1];
[_tableview reloadRowsAtIndexPaths:indexArray withRowAnimation:UITableViewRowAnimationAutomatic];
7. UITableview复用注意
在cell复用的时候前往要注意要将添加视图放在初始化里面,而不是外面,例如放在自己写的init方法里或者在if(cell == nil)里,这样当cell重新加载才不会重复添加视图到时界面视图重叠。
相关文章推荐
- android:allowBackup=true 数据备份(adb backup)+查看(abe unpack backup.ab backup.tar)+恢复(adb re)
- [LeetCode 232] Implement Queue using Stacks
- easy ui 下拉级联效果 ,下拉框绑定数据select控件
- 代码手写UI,xib和StoryBoard间的博弈,以及Interface Builder的一些小技巧
- easy ui 下拉框绑定数据select控件
- String、StringBuffer、StringBuilder
- easyui常用控件及样式收藏
- UITextView垂直方向上光标和文字显示文字的问题
- Android UI系列--对话框(一)(AlertDialog,TimePickerDialog,DatePickerDialog,ProgressDialog)
- UIColor+Hex
- css3之 media query 使用(转)
- UIView 坐标转换
- burpsuite+sqlmap跨登录验证SQL注入
- Druid数据源配置
- [MySQL FAQ]系列 — 线上环境到底要不要开启query cache
- EasyUI DataGrid undefined处理
- JUint4 简单测试代码
- 22个值得收藏的android开源代码-UI篇
- Android 应用程序窗体显示状态操作(requestWindowFeature()的应用)
- 利Android AQuery中ajax访问SSH搭建的后台Java Web服务器