IOS UI UITableView
-、建立 UITableView
DataTable = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, 320, 420)];
[DataTable setDelegate:self];
[DataTable setDataSource:self];
[self.view addSubview:DataTable];
[DataTable release];
二、UITableView各Method说明
//Section总数
- (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView{
return TitleData;
}
// Section Titles
//每个section显示的标题
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section{
return @"";
}
//指定有多少个分区(Section),默认为1
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 4;
}
//指定每个分区中有多少行,默认为1
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
}
//绘制Cell
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *SimpleTableIdentifier = @"SimpleTableIdentifier";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:
SimpleTableIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
reuseIdentifier: SimpleTableIdentifier] autorelease];
}
cell.imageView.image=image;//未选cell时的图片
cell.imageView.highlightedImage=highlightImage;//选中cell后的图片
cell.text=//.....
return cell;
}
//行缩进
-(NSInteger)tableView:(UITableView *)tableViewindentationLevelForRowAtIndexPath:(NSIndexPath *)indexPath{
NSUInteger row = [indexPath row];
return row;
}
//改变行的高度
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
return 40;
}
//定位
[TopicsTable setContentOffset:CGPointMake(0, promiseNum * 44 + Chapter * 20)];
//返回当前所选cell
NSIndexPath *ip = [NSIndexPath indexPathForRow:row inSection:section];
[TopicsTable selectRowAtIndexPath:ip animated:YESscrollPosition:UITableViewScrollPositionNone];
[tableView setSeparatorStyle:UITableViewCellSelectionStyleNone];
//选中Cell响应事件
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
[tableView deselectRowAtIndexPath:indexPath animated:YES];//选中后的反显颜色即刻消失
}
//判断选中的行(阻止选中第一行)
-(NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSUInteger row = [indexPath row];
if (row == 0)
return nil;
return indexPath;
}
//划动cell是否出现del按钮
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
}
//编辑状态
- (void)tableView:(UITableView *)tableViewcommitEditingStyle:(UITableViewCellEditingStyle)editingStyle
forRowAtIndexPath:(NSIndexPath *)indexPath
{
}
[topicsTable setContentSize:CGSizeMake(0,controller.promiseNum * 44)];
//右侧添加一个索引表
- (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView{
}
//返回Section标题内容
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section{
}
//自定义划动时del按钮内容
- (NSString *)tableView:(UITableView *)tableView
titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath
//跳到指的row or section
[tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] atScrollPosition:UITableViewScrollPositionBottom animated:NO];
三、在UITableViewCell上建立UILable多行显示
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
UILabel *Datalabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 0, 320, 44)];
[Datalabel setTag:100];
Datalabel.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
[cell.contentView addSubview:Datalabel];
[Datalabel release];
}
UILabel *Datalabel = (UILabel *)[cell.contentView viewWithTag:100];
[Datalabel setFont:[UIFont boldSystemFontOfSize:18]];
Datalabel.text = [data.DataArray objectAtIndex:indexPath.row];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
return cell;
}
//选中cell时的颜色
typedef enum {
UITableViewCellSelectionStyleNone,
UITableViewCellSelectionStyleBlue,
UITableViewCellSelectionStyleGray
} UITableViewCellSelectionStyle
//cell右边按钮格式
typedef enum {
UITableViewCellAccessoryNone, // don't show any accessory view
UITableViewCellAccessoryDisclosureIndicator, // regular chevron. doesn't track
UITableViewCellAccessoryDetailDisclosureButton, // blue button w/ chevron. tracks
UITableViewCellAccessoryCheckmark // checkmark. doesn't track
} UITableViewCellAccessoryType
//是否加换行线
typedef enum {
UITableViewCellSeparatorStyleNone,
UITableViewCellSeparatorStyleSingleLine
} UITableViewCellSeparatorStyle
//改变换行线颜色
tableView.separatorColor = [UIColor blueColor];
转载于:https://www.cnblogs.com/yuqingzhude/p/4836537.html
IOS UI UITableView相关推荐
- iOS UI 之聊天室渐变蒙层效果
iOS UI 开发中,我们已接触过不少 layer 相关设置,如常见设置按钮的圆角效果 UIButton *button = [UIButton buttonWithType:UIButtonType ...
- iOS 8 UITableView分隔符插入0不起作用
本文翻译自:iOS 8 UITableView separator inset 0 not working I have an app where the UITableView 's separat ...
- IOS UI开发基础之超级猜图完整版本-08
IOS UI开发基础之超级猜图完整版本-08 // // ViewController.m // 09-超级猜图 // // Created by 鲁军 on 2021/1/31. //#import ...
- iOS UI 开发按钮的使用
IOS UI 开发之按钮的使用 // // ViewController.m // 02按钮的使用介绍 // // Created by 鲁军 on 2021/1/26. //#import &quo ...
- 基于 KIF 的 iOS UI 自动化测试和持续集成
客户端 UI 自动化测试是大多数测试团队的研究重点,本文介绍猫眼测试团队在猫眼 iOS 客户端实践的基于 KIF 的 UI 自动化测试和持续集成过程. 一.测试框架的选择 iOS UI 自动化测试框架 ...
- IOS UI Automation 学习之常用类,方法和模拟手势
为什么80%的码农都做不了架构师?>>> IOS UI Automation 学习之常用类,方法和模拟手势 常用类结构图 作者不擅长作画,如果有好的画此类图形的工具,可以留言, ...
- android 布局可大可小,UI设计教程之:ios与android ui适配(将IOS UI转换成Android经验畅谈)...
内容提要:这是UI设计系列教程之ios与android ui适配经验畅谈.文章作者介绍了自己将IOS UI转换成Android经验,包括:不要直接转换.了解单位和组件缩放格式.屏幕尺寸DP和像素的换算 ...
- ios ui自动化测试_Xcuitest的ios自动化ui测试
ios ui自动化测试 Who knew automated UI Testing could be so easy! Well, I guess Apple did. Automated UI Te ...
- iOS UI入门——使用Objective-C和Swift简单实现UITableView
Objective-C代码: #import "ViewController.h"@interface ViewController ()<UITableViewDelega ...
最新文章
- 感知哈希算法(perceptual hash algorithm),
- Linux网络设置2——虚拟机中的Linux和Windows网络互通设置
- linux 下面编译FFMPEG
- 当一个程序员真正掌握算法之后,会变得有多强...
- 没有RunInstallerAttribute.Yes的公共安装程序。
- [Qt入门]QTreeWidget控件创建
- html页面返回原理,浏览器输入URL到界面显示(HTML渲染)发生了什么?
- diabetes影响因子2017_Journal of Diabetes
- PhpYun人才系统 与 Discuz 社区 通过 Ucenter 做会员整合
- 在Oracle中添加用户登录名称
- Linux运行jnetpcap程序(含配置步骤)
- .net core 多平台开发体验
- 自然语言处理NLP星空智能对话机器人系列:论文解读 How Good is Your Tokenizer? (你的词元分析器有多好?多语言模型的单语性能研究)
- scipy库中的leastsq函数
- [笑话]让古龙看了要痛哭的高考作文(作品相当强,但得了零分,据说被破格入取了)!!!...
- python爬取拉勾网_python 爬取拉勾网实战
- 树莓派 3B+ HDMI 分辨率改不了 和一些坑坑洼洼
- 主引导记录、启动扇区
- python语言的变量_自兴人工智能------Python语言的变量认识及操作
- 教你如何安慰失戀人?
热门文章
- #25 centos7(RHEL)系列操作系统的启动流程、systemd的特性、与命令systemctl的使用...
- 《Oracle高性能自动化运维》一一第1章 Linux下的Oracle
- docker容器之RabbitMQ
- iOS学习之NSBundle介绍和使用
- 【SAP HANA】关于SAP HANA中带层次结构的Analytic View创建、激活状况下在系统中生成对象的研究...
- jboss4中手动部署EJB(jboss4.0.2+ejb2.0+j2sdk5.0+xpsp2)
- IBM X60/X61无光驱安装XP
- 为什么Docker,Vagrant和Ansible等工具比以往更热门
- (32)Gulp CSS hack 与 Autoprefixer
- (49)移动端开发之流式布局(百分比布局)