tableview delegate 详解
来源:互联网 发布:冰岛 知乎 编辑:程序博客网 时间:2024/05/17 03:42
#pragma TableViewDelegate
分组
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return self.dataSource.count;
}
每组的行数
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [[self.dataSourceobjectAtIndex:section]count];
}
cell高度
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.section ==0) {
return 70;
}
else
{
return 44;
}
}
cell头的高度
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
if (section == 0)
{
return 0;
}
else
{
return 25;
}
}
cell脚的高度
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
if (section == 3 ) {
return 70;
}
else
{
return 0;
}
}
脚的自定义
-(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
if (section == 3) {
UIView * footView = [[UIViewalloc]initWithFrame:CGRectMake(0,0, tableView.frame.size.width,70)];
UIButton *button1=[[UIButtonalloc]initWithFrame:CGRectMake(35,20, tableView.frame.size.width-35*2,40)];
[button1 setBackgroundImage:[UIImageimageNamed:@"01确定按钮.png"]forState:UIControlStateNormal ];
[button1 setTitle:@"退出登录"forState:UIControlStateNormal ];
[button1 addTarget:selfaction:@selector(quite:)forControlEvents:UIControlEventTouchUpInside ];
[footView setBackgroundColor:[UIColorclearColor]];
[footViewaddSubview:button1];
return footView ;
}
else
{
return 0;
}
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString * identifier =@"identifier3";
setTableViewCell * cell = (setTableViewCell*)[[tableViewdequeueReusableCellWithIdentifier:identifier]lastObject];
if (cell == nil)
{
cell = [[[NSBundlemainBundle]loadNibNamed:@"setTableViewCell"owner:selfoptions:nil]lastObject];
[cell setSelectionStyle:UITableViewCellSelectionStyleGray];
}
if (indexPath.section ==0)
{
cell.TX_image.frame =CGRectMake(20,20, 40, 40);
cell.MX_label.frame =CGRectMake(70,30, 200, 30);
cell.TP_image.frame =CGRectMake(SCREEN_WIDTH-30,80/2-14/2 ,7,14);
}
else
{
cell.TX_image.frame =CGRectMake(20,20, 20, 20);
cell.MX_label.frame =CGRectMake(50,10, 200, 30);
cell.TP_image.frame =CGRectMake(SCREEN_WIDTH-30,44/2-14/2,7, 14);
}
NSString * TX = [[[self.dataSourceobjectAtIndex:indexPath.section]objectAtIndex:indexPath.row]objectForKey:@"TX"];
cell.TX_image.image = [UIImageimageNamed:TX];
cell.MX_label.text = [[[self.dataSourceobjectAtIndex:indexPath.section]objectAtIndex:indexPath.row]objectForKey:@"MC"];
cell.TP_image.image = [UIImageimageNamed:@"setting_arrow.png"];
return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.section ==0)
{
NSLog(@"啊哈0");
privateMessageViewController * pM = [[privateMessageViewControlleralloc]init];
[self.navigationControllerpushViewController:pM animated:YES];
}
else if (indexPath.section ==1)
{
if (indexPath.row ==0)
{
NSString * str = @"child";
[selfchildOrClass:str];
}
else
{
NSString * str = @"class";
[selfchildOrClass:str];
}
}
else if (indexPath.section ==2)
{
NSLog(@"啊哈2");
NotFriendlyViewController * notFriendly = [[NotFriendlyViewControlleralloc]init];
[self.navigationControllerpushViewController:notFriendly animated:YES];
}
else if (indexPath.section ==3)
{
if (indexPath.row ==0) {
privateSetViewController * privaSet = [[privateSetViewControlleralloc]init];
[self.navigationControllerpushViewController:privaSet animated:YES];
}
else if (indexPath.row ==1)
{
FeedBackViewController * feedBack = [[FeedBackViewControlleralloc]init];
[self.navigationControllerpushViewController:feedBack animated:YES];
}
}
}
- tableview delegate 详解
- (作业)TableView、Delegate、DataSource
- tableview中的delegate、DataSource原理
- Delegate详解
- delegate详解
- tableview 详解
- TableView详解
- tableView详解
- TableView详解
- TableView详解
- tableview 详解
- TableView详解
- tableView详解
- TableView详解
- C# delegate 详解
- 详解C#中的Delegate
- iOS delegate详解
- jQuery.delegate() 函数详解
- stringstream 清空 方法
- 数据库建立索引的原则
- phpstorm 配置代码自动上传功能
- OC中字典dictrionary的应用
- JavaScript 编程学习中的一些问题
- tableview delegate 详解
- Console命令详解,让调试js代码变得更简单
- Linux下socket阻塞、非阻塞详解
- OpenSessionInViewFilter原理以及为什么要用OpenSessionInViewFilter
- Java NIO Java NIO 概述
- cocos code ide里面字体大小的调整
- 2012 亚马逊在线笔试题目2
- #Android笔记#android无法使用scrollTo定位的解决办法。
- setTimeout()和setInterval() 何时被调用执行