博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
tableView使用的各项注意点
阅读量:7009 次
发布时间:2019-06-28

本文共 1717 字,大约阅读时间需要 5 分钟。

hot3.png

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

你可能感兴趣的文章
计算1到100的所有整数中9出现的次数
查看>>
linux下配置mysql解析 遇到新问题两个。
查看>>
查看刀片服务器MAC地址方法 zhoulb@dc
查看>>
VI中显示行号
查看>>
把C代码当shell脚本来执行
查看>>
今年的9月,只能怀念
查看>>
Linux 日志
查看>>
我的友情链接
查看>>
【Android】AndroidStudio空指针解决之:listview与adapter的使用报空 java.lang.NullPointerException...
查看>>
Rsync实现Windows系统与Linux文件同步
查看>>
简单工厂模式( Simple Factory Pattern )
查看>>
CentOS 7安装laravel 5.5.28
查看>>
SQL Server 2005 创建Oracle10g 的链接服务器
查看>>
菜单项启动Activity
查看>>
Ubuntu下安装Python的Tkinter和Pmw库
查看>>
安装Nginx+Lua开发环境
查看>>
nginx nginx.pid无故文件丢失,日志无法正常轮转
查看>>
我的友情链接
查看>>
XML中元素VS属性
查看>>
wepy - 小程序快速开发框架
查看>>