您的位置:首页 > 产品设计 > UI/UE

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重新加载才不会重复添加视图到时界面视图重叠。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: