快上网专注成都网站设计 成都网站制作 成都网站建设
成都网站建设公司服务热线:028-86922220

网站建设知识

十年网站开发经验 + 多家企业客户 + 靠谱的建站团队

量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决

iOS培训教程——UITableView详解

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

宜宾网站建设公司创新互联公司,宜宾网站设计制作,有大型网站制作公司丰富经验。已为宜宾上1000家提供企业网站建设服务。企业网站搭建\成都外贸网站建设要多少钱,请找那个售后服务好的宜宾做网站的公司定做!

-、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培训讲师易慧云,我为“爱心”代言!只要你喜欢、有兴趣,可以随时关注我。


本文标题:iOS培训教程——UITableView详解
文章位置:http://6mz.cn/article/jpddih.html

其他资讯