UITableViewController的使用
如果整个程序界面都只是使用UITableView来搭建,一般需要如下步骤:
(1)向界面上拖一个UITableView
(2)设置数据源
(3)设置代理
(4)遵守代理协议
+ (instancetype)cellWithTableView:(UITableView *)tableView
{
static NSString *ID = @"cellID";
ATDemoCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
if (cell == nil) {
cell = [[ATDemoCell alloc] initWithStyle:(UITableViewCellStyleDefault) reuseIdentifier:ID];
}
return cell;
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
// 在此处定义控件
}
return self;
}
在cellForRowAtIndexPath数据源里调用
ATDemoCell *cell = [ATDemoCell cellWithTableView:tableView];
分割线设置
//设置分割线
[tableView setSeparatorInset:UIEdgeInsetsMake(0, -67, 0, 0)];
//分割线颜色
self.tableView.separatorColor = [UIColor redColor]; //隐藏分割线
self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
//隐藏多余分割线
self.tableView.tableFooterView = [[UIView alloc] init];
取消选中样式
//取消选中样式
cell.selectionStyle = UITableViewCellSeparatorStyleNone;
设置背景色
// 改变整个tableView的颜色
tableView.backgroundColor = [UIColor greenColor] // 设置选中的背景色
UIView *selectedBackgroundView = [[UIView alloc] init];
selectedBackgroundView.backgroundColor = [UIColor redColor];
cell.selectedBackgroundView = selectedBackgroundView; // 设置默认的背景色 1
cell.backgroundColor = [UIColor blueColor]; // 设置默认的背景色 2
UIView *backgroundView = [[UIView alloc] init];
backgroundView.backgroundColor = [UIColor greenColor];
cell.backgroundView = backgroundView;
右边指示器显示,比如箭头、打勾,也可以自定义图片等等
// 显示箭头
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
// 自定义显示,如开关Switch
cell.accessoryView = [[UISwitch alloc] init];
设置tableview 不能滚动
self.tableView.scrollEnabled =NO;
UITableViewController的使用的更多相关文章
- iOS UITableView 与 UITableViewController
很多应用都会在界面中使用某种列表控件:用户可以选中.删除或重新排列列表中的项目.这些控件其实都是UITableView 对象,可以用来显示一组对象,例如,用户地址薄中的一组人名.项目地址. UITab ...
- UITableViewController和XML解析还有地图的简单结合
然后我的代码就按照上面的这个顺序输出. #import <Foundation/Foundation.h> #import <MapKit/MapKit.h> @interfa ...
- UITableViewController和延时执行、自定义控件
1.在UITableViewController中,self.view就是self.tableView, 两个对象的指针地址是一样的 2.自定义类继承UITableViewCell, 重写父类方法 / ...
- iOS--通讯录(UITableViewController)
本文主要实现通讯录的部分功能(分组名.索引.分组的组名)等等功能: 废话不多说了,先上效果图: 在工程中需要导入一个plist文件,文件图如图: 工程目录文件如图: 工程程序如图所示: RootTab ...
- iOS--(UITableViewCell)、(UITableViewController)微信个人主页
本文主要实现了微信的个人主页的设置: 目录文件如下: 实现代码如下: RootTableViewController.h #import <UIKit/UIKit.h> @interfac ...
- iOS UITableView , UITableViewController ,UITableViewCell实现全国各省市遍历,选择相应的地区
我们先看一下效果 代码如下 首先是第一个页面 rootTableViewController.h #import <UIKit/UIKit.h> #im ...
- iOS7上在xib中使用UITableViewController设置背景色bug
今天用xcode5.1设置xib中,用静态的方式设置UITableViewController中的tableview,把tableview中的backgroundColor改变后,xib上有效果,但是 ...
- UITableView & UITableViewController
内容概要: 本文先讲解了UITableView概述,然后主要从应用方面讲解了UITableViewController(包括add.delete.move单元cell的操作,以及UITableView ...
- iOS - UITableViewController
前言 NS_CLASS_AVAILABLE_IOS(2_0) @interface UITableView : UIScrollView <NSCoding> @available(iOS ...
- UITableViewController 滚动引起的cocos2d动画暂停问题的解决
UITableViewController 滚动引起的cocos2d动画暂停问题的解决 之前在使用UITableViewController进行滚动时,cocos2d的动画会暂停,直至滚动完毕才会继续 ...
随机推荐
- 常用web资源
ip相关 新浪:http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js&ip=220.181.38.110 (不带参数本机) ...
- [solution]xdebug正确配置,但不显示错误信息
一开始以为是配置问题,其实不是,折腾了好久,貌似中文网页很少有人提到这事,更别提解决之道! 最好还是用英文关键词google之:得如下网页 https://bugs.launchpad.net/ubu ...
- 3dContactPointAnnotationTool开发日志(二二)
昨天是实现了显示GameObject子GameObject的选项卡功能,今天就是要让statusPanel可以控制它们的位置.旋转和缩放了. 没什么难的,对应选项卡绑定上对应的物体或子物体即可 ...
- java 文件操作知识点
1.每个文件以一个文件路径和文件名称进行表示,在不同的操作系统环境下,文件路径的表示形式是不一样的,例如在Windows操作系统中一般的表示形式为C:\windows\system,而Unix上的表示 ...
- coreldraw x5提示盗版警告解决方法
CorelDRAW是一款图形图像软件,大多数用户使用的都是coreldraw x5破解版,所以基本上都收到了coreldraw x5提示盗版警告,导致不能用,没关系,绿茶小编有解决方法. coreld ...
- 【ADO.NET】ADO.NET知识点
ADO.NET 是一组向 .NET 程序员公开数据访问服务的类.提供了对各种关系数据.XML 和应用程序数据的访问. 所有的数据访问类位于System.Data.dll中.System.Data包含了 ...
- matlab函数列表(A~Z)【转】
A a abs 绝对值.模.字符的ASCII码值acos 反余弦acosh 反双曲余弦acot 反余切acoth 反双曲余切acsc 反余割acsch 反双曲余割align 启动图形对象几何位置排列工 ...
- 同步锁(synchronized)使用三要素
1.代码被多个线程访问 2.代码中有共享的数据 3.共享数据被多个语句操作
- csrf漏洞攻击手段和影响详解
针对web应用安全中csrf漏洞两种典型的攻击方式:即输入和执行,这种简单模式下的攻击手段以及中途包含确认页面的攻击方法. 图解什么是csrf漏洞 我们先进行约束,比如存在csrf漏洞的网站叫webA ...
- P1365 WJMZBMR打osu! / Easy
题目背景 原 维护队列 参见P1903 题目描述 某一天WJMZBMR在打osu~~~但是他太弱逼了,有些地方完全靠运气:( 我们来简化一下这个游戏的规则 有 nnn 次点击要做,成功了就是o,失败了 ...