UiTableview的常用小知识汇集

  • 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重新加载才不会重复添加视图到时界面视图重叠。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值