iOS培训教程——UITableView详解

发布时间:2020-07-07 15:47:08 作者:蓝鸥易荟云
来源:网络 阅读:459

人这一路走来什么才是最富有的?回头想想,风风火火的走了一圈,才发现原来拥有了知识、拥有技术的人才是最富有的,这些任谁也不能抢走它,只属于你自己。现在还年轻的你一定不要迷失了方向,找准位置,走好接下来的每一步,那么iOS培训是不是你要走的路呢?

-、UITableView的建立

DataTable=[[UITableViewalloc]initWithFrame:CGRectMake(0,0,320,420)];
[DataTablesetDelegate:self];
[DataTablesetDataSource:self];
[self.viewaddSubview:DataTable];
[DataTablerelease];
二、UITableView各Method说
//Section总数
-(NSArray*)sectionIndexTitlesForTableView:(UITableView*)tableView{
returnTitleData;
}


//SectionTitles
//每个section显示的标题
-(NSString*)tableView:(UITableView*)tableViewtitleForHeaderInSection:(NSInteger)section{
return@"";
}


//指定有多少个分区(Section),默认为1
-(NSInteger)numberOfSectionsInTableView:(UITableView*)tableView{
return4;
}


//指定每个分区中有多少行,默认为1
-(NSInteger)tableView:(UITableView*)tableViewnumberOfRowsInSection:(NSInteger)section{
}


//绘制Cell
-(UITableViewCell*)tableView:(UITableView*)tableViewcellForRowAtIndexPath:(NSIndexPath*)indexPath{
staticNSString*SimpleTableIdentifier=@"SimpleTableIdentifier";

UITableViewCell*cell=[tableViewdequeueReusableCellWithIdentifier:
SimpleTableIdentifier];

if(cell==nil){
cell=[[[UITableViewCellalloc]initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:SimpleTableIdentifier]autorelease];

}
cell.p_w_picpathView.p_w_picpath=p_w_picpath;//未选cell时的图片
cell.p_w_picpathView.highlightedImage=highlightImage;//选中cell后的图片
cell.text=//.....
returncell;
}


//行缩进
-(NSInteger)tableView:(UITableView*)tableViewindentationLevelForRowAtIndexPath:(NSIndexPath*)indexPath{
NSUIntegerrow=[indexPathrow];
returnrow;
}


//改变行的高度
-(CGFloat)tableView:(UITableView*)tableViewheightForRowAtIndexPath:(NSIndexPath*)indexPath{
return40;
}


//定位
[TopicsTablesetContentOffset:CGPointMake(0,promiseNum*44+Chapter*20)];


//返回当前所选cell
NSIndexPath*ip=[NSIndexPathindexPathForRow:rowinSection:section];
[TopicsTableselectRowAtIndexPath:ipanimated:YESscrollPosition:UITableViewScrollPositionNone];


[tableViewsetSeparatorStyle:UITableViewCellSelectionStyleNone];


//选中Cell响应事件
-(void)tableView:(UITableView*)tableViewdidSelectRowAtIndexPath:(NSIndexPath*)indexPath{

[tableViewdeselectRowAtIndexPath:indexPathanimated:YES];//选中后的反显颜色即刻消失
}


//判断选中的行(阻止选中第一行)
-(NSIndexPath*)tableView:(UITableView*)tableViewwillSelectRowAtIndexPath:(NSIndexPath*)indexPath
{
NSUIntegerrow=[indexPathrow];
if(row==0)
returnnil;
returnindexPath;
}


//划动cell是否出现del按钮
-(BOOL)tableView:(UITableView*)tableViewcanEditRowAtIndexPath:(NSIndexPath*)indexPath{
}


//编辑状态
-(void)tableView:(UITableView*)tableViewcommitEditingStyle:(UITableViewCellEditingStyle)editingStyle
forRowAtIndexPath:(NSIndexPath*)indexPath
{

[topicsTablesetContentSize:CGSizeMake(0,controller.promiseNum*44)];
//右侧添加一个索引表
-(NSArray*)sectionIndexTitlesForTableView:(UITableView*)tableView{
}

//返回Section标题内容
-(NSString*)tableView:(UITableView*)tableViewtitleForHeaderInSection:(NSInteger)section{
}

//cell右边按钮格式

typedefenum{
UITableViewCellAccessoryNone,//don'tshowanyaccessoryview
UITableViewCellAccessoryDisclosureIndicator,//regularchevron.doesn'ttrack
UITableViewCellAccessoryDetailDisclosureButton,//bluebuttonw/chevron.tracks
UITableViewCellAccessoryCheckmark//checkmark.doesn'ttrack
}UITableViewCellAccessoryType

//是否加换行线

typedefenum{
UITableViewCellSeparatorStyleNone,
UITableViewCellSeparatorStyleSingleLine
}UITableViewCellSeparatorStyle

//改变换行线颜色lyttzx.com

leView.separatorColor=[UIColorblueColor];

//自定义划动时del按钮内容
-(NSString*)tableView:(UITableView*)tableView
titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath*)indexPath


//跳到指的roworsection
[tableViewscrollToRowAtIndexPath:[NSIndexPathindexPathForRow:0inSection:0]atScrollPosition:UITableViewScrollPositionBottomanimated:NO];

三、在UITableViewCell上建立UILable多行显示

iOS培训教程——UITableView详解

//选中cell时的颜色

typedefenum{
UITableViewCellSelectionStyleNone,
UITableViewCellSelectionStyleBlue,
UITableViewCellSelectionStyleGray
}UITableViewCellSelectionStyle

做人也要像蜡烛一样,在有限的一生中有一分热发一分光,给人以光明,给人以温暖。我是iOS培训讲师易慧云,我为“爱心”代言!只要你喜欢、有兴趣,可以随时关注我。

推荐阅读:
  1. iOS UITableView表格索引
  2. IOS UITableView表格视图详解

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

ios培训 北京ios培训 手机开发 手 ev

上一篇:数据通信模型

下一篇:关于python里os的简介

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》