iOS-UITableView的使用
//将类与代理类建立关联,用代码或者利用连线的方式来实现
self.tableView.dataSource = self;
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
- (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView{
return [self.carsGroups valueForKeyPath:@"title"];
- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath*)indexPath
{
if (indexPath.row == 0) { // 第一行是插入样式
return UITableViewCellEditingStyleInsert;
}else{
return UITableViewCellEditingStyleDelete;
}
//设置滚动区域的偏移
self.tableView.rowHeight = 60;
//设置分割线
self.tableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
//设置分割线颜色
self.tableView.separatorColor = [UIColor brownColor];
//cell不允许选中
self.tableView.allowsSelection = NO;
//设置分组行高
self.tableView.sectionHeaderHeight = 50;
//进入编辑状态
self.tableView.editing = YES;
UISwitch *swithBth = [[UISwitch alloc] init];
UISwitch *swithBth1 = [[UISwitch alloc] init];
self.tableView.tableHeaderView = swithBth;
self.tableView.tableFooterView = swithBth1;
全部或者局部reload,都是触发tableView:cellForRowAtIndexPath:方法,创建或重用cell,局部刷新cell时还可实现动画效果。而cell.textLabel.text是直接赋值,只是更新了页面上的label属性,不触发任何事件。
[self.tableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionBottom animated:YES];
如果tableview包含tableFooterView则需要自己定位
[UIView animateWithDuration:0.5 animations:^{
CGFloat height = self.tableView.contentSize.height - self.tableView.frame.size.height;
[self.tableView setContentOffset:CGPointMake(0, height)];
}];
CeLL重用
Cell常用属性
/*设置backgroundView和selectedBackgroundView的背景颜色时不要直接设置cell.backgroundView.backgroundColor和cell.selectedBackgroundView.backgroundColor
应该创建ImageView后设置其backgroundColor再赋值*/
UIImageView *view = [[UIImageView alloc] init];
view.backgroundColor = [UIColor greenColor];
cell.backgroundView = view;
view1.backgroundColor = [UIColor blueColor];
//此时cell.textLabel.text = @"textLabel";
//如果在cell.backgroundColor = [UIColor redColor];后面,
cell.backgroundColor = [UIColor redColor];
NSString *ID = @"contact_cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
if (cell == nil) { //用户不会执行下面的语句
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:ID];
}
静态的Cell需要设置tableView的Content属性为Static Cells,然后再设置分组数量,再点击每个分组设置row
6我想把第一个cell显示的数据 向后缩进10个像素其他的cell不变怎么办呢
其实tableview已经给我提供了这样的函数
-(NSInteger)tableView:(UITableView *)tableView indentationLevelForRowAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.row ==0) {
return10;
}
return
0;
}
iOS-UITableView的使用的更多相关文章
- IOS UITableView NSIndexPath属性讲解
IOS UITableView NSIndexPath属性讲解 查看UITableView的帮助文档我们会注意到UITableView有两个Delegate分别为:dataSource和deleg ...
- iOS UITableView划动删除的实现
标签:划动删除 iphone 滑动删除 ios UITableView 原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 .作者信息和本声明.否则将追究法律责任.http://rainb ...
- iOS UITableView Tips(2)
#TableView Tips(2) (本来想一章就结束TableView Tips,但是发现自己还是太天真了~too young,too simple) ##架构上的优化 在Tips(1)中指出了一 ...
- iOS UITableView 与 UITableViewController
很多应用都会在界面中使用某种列表控件:用户可以选中.删除或重新排列列表中的项目.这些控件其实都是UITableView 对象,可以用来显示一组对象,例如,用户地址薄中的一组人名.项目地址. UITab ...
- iOS - UITableView中Cell重用机制导致Cell内容出错的解决办法
"UITableView" iOS开发中重量级的控件之一;在日常开发中我们大多数会选择自定Cell来满足自己开发中的需求, 但是有些时候Cell也是可以不自定义的(比如某一个简单的 ...
- iOS UITableView 引起的崩溃问题
其实 UITableView 应该是在iOS开发中使用最频繁的一个控件,一次同事之间聊天玩笑的说“一个页面,要是没使用UITableView,就好像称不上是一个页面”.虽然是个最常见的控件,但是他的强 ...
- IOS UITableView下拉刷新和上拉加载功能的实现
在IOS开发中UITableView是非常常用的一个功能,而在使用UITableView的时候我们经常要用到下拉刷新和上拉加载的功能,今天花时间实现了简单的UITableView的下拉刷新和上拉加载功 ...
- iOS UITableView的分割线短15像素,移动到最左边的方法(iOS8)
有好几个朋友问我ios 分割线端了一些 如何解决,于是我就写一篇博客吧.为什么我说是少了15像素呢?首先我们拖拽一个默认的tableview 控件! 看下xcode5 面板的inspector(检查器 ...
- iOS:UITableView 方法 属性
参考:https://developer.apple.com/library/iOS/documentation/UIKit/Reference/UITableView_Class/Reference ...
- iOS UITableView左滑操作功能的实现(iOS8-11)
WeTest 导读 本文主要是介绍下iOS 11系统及iOS 11之前的系统在实现左滑操作功能上的区别,及如何自定义左滑的标题颜色.字体大小. 一.左滑操作功能实现 1.如果左滑的时候只有一个操作按钮 ...
随机推荐
- go 变量的定义方式
var a int a = 1 var a,b int a =1 b = 2 var a,b = 1,2 var s string = "hello world" a, b := ...
- 2019牛客暑期多校训练营(第九场)The power of Fibonacci——循环节&&CRT
题意 求 $\displaystyle \sum_{i=1}^n F_i^m $,($1 \leq n\leq 10^9,1 \leq m\leq 10^3$),答案对 $10^9$ 取模. 分析 ...
- 到spring官网创建第一个springboot工程
登录到spring的官网,直接生成一个,然后倒入本地工程就可以了. https://start.spring.io/ 点击创建的时候. 就等于下载了这个工程. 下载后,倒入到我们的maven工程可以直 ...
- 2019 ICPC Asia Yinchuan Regional
目录 Contest Info Solutions A. Girls Band Party B. So Easy D. Easy Problem E. XOR Tree F. Function! G. ...
- \ddd和\xddd 转义序列
转自 http://blog.csdn.net/todd911/article/details/8851475 书中有如下描述: \ddd ddd表示1~3个八进制数字,这个转义符表示的字符就是给定 ...
- 8、RDD持久化
一.RDD持久化 1.不使用RDD持久化的问题 2.RDD持久化原理 Spark非常重要的一个功能特性就是可以将RDD持久化在内存中.当对RDD执行持久化操作时,每个节点都会将自己操作的RDD的par ...
- linux 查看某个进程内存占用情况命令
1.先用ps查询进程号 ps -aux|grep 进程名字 2.查看更详细的内存占比 cat /proc/3664/status 返回结果:(其中VmRSS为进程所占用的内存)
- Yarn状态机
1 概述 为了增大并发性,Yarn采用事件驱动的并发模型,将各种处理逻辑抽象成事件和调度器,将事件的处理过程用状态机表示.什么是状态机? 如果一个对象,其构成为若干个状态,以及触发这些状态发生相互转移 ...
- json页面解析
List<TjfxDTO> cyjbList = new ArrayList<TjfxDTO>(); cyjbList=tjfxService.cyjb_wcjd(tjfxDT ...
- 查看日志tail命令
打开终端,连接jboss: 命令: tail -f -n 500 /var/log/wildfly/wrapper.log