tableView使用的各项注意点

1.取消tableView上的分割线。


    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;

    

2.设置cell的选中样式。

   self.selectionStyle = .None


3. 设置cell滑动 出现 删除的按钮 —“滑动删除功能”(数据源方法)

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {

}


4.编辑滑动删除的文字。

- (NSString *)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath {

   
return @"删除";

}


5.滑动隐藏键盘(滑动退出键盘)

- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView {

[self.messageText endEditing:YES];

}

6.让tableView的组头不随tableView的滚动进行滚动。

 self.tableView.sectionHeaderHeight = 50;


//代理方法—tableView必须是plain样式。

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{


   
NSLog(@"" );
   
return [self setUpHeadview];

}


7.让tableView没有弹簧效果。

self.tableView.bounces = NO;


8.设置tableViewCell右侧的辅助视图   ">"

[cell setAccessoryType:UITableViewCellAccessoryDisclosureIndicator];


9..设置tableView的分割线顶头

  self.tableView.separatorInset = UIEdgeInsetsZero;

10.将多余的tableView的分割线去掉。

  self.tableFooterView = [[UIViewalloc]init];


11.

用通知进行传值。

>>>在view中

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
   
   
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
 
    [[
NSNotificationCenter defaultCenter]postNotificationName:@"passType" object:cell.textLabel.text];
   

}


>>>在控制器中

 [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(getType:) name:@"passType" object:nil];
}
- (
void)getType:(NSNotification *)note{
   
_typeTextField.text = note.object;
    [
self.navigationController popToViewController:self animated:YES];

}


转载于:https://my.oschina.net/u/2613740/blog/666107

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值