• 实现TabelView的多个cell布局


    - (void)viewDidLoad {

        [super viewDidLoad];

        self.LabelArray=[[NSMutableArray alloc]initWithObjects:@"个人资料",@"我的收藏",@"我的消息",@"我的房源",@"我的足迹",@"意见反馈",@"关于心家", nil];

        self.PicArray=[[NSMutableArray alloc]initWithObjects:@"c11",@"c12",@"c13",@"c14",@"c15",@"c16",@"c17",nil];

        // Do any additional setup after loading the view, typically from a nib.

    }

    //显示行数

    -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{

    //    return self.PicArray.count;

        switch (section) {

            case 0:

                return 1;

                break;

            case 1:

                return 4;

                break;

                

            default:

                return 1;

                break;

        }

        

    }

    //section的个数

    -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{

        return 3;

    }

     

     

     

    //重用机制,重用cell

    -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{

        TTTableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:@"cellTest" forIndexPath:indexPath];

        switch (indexPath.section) {

            case 0:

                cell.ImageViewT.image=[UIImage imageNamed:self.PicArray[0]];

                cell.LabelViewT.text=self.LabelArray[0];

                break;

            case 1:

                

                cell.ImageViewT.image=[UIImage imageNamed:self.PicArray[indexPath.row+1]];

                cell.LabelViewT.text=self.LabelArray[indexPath.row+1];

                break;

            

            case 2:

                cell.ImageViewT.image=[UIImage imageNamed:self.PicArray[indexPath.row+5]];

                cell.LabelViewT.text=self.LabelArray[indexPath.row+5];

                break;

                

            default:

                break;

        }

        

        return cell;

    }

    //点击跳转

    -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{

        if(indexPath.section==0){

            [self performSegueWithIdentifier:@"1" sender:indexPath];

            

        }else if(indexPath.section==1){

            switch (indexPath.row) {

                case 0:

                    [self performSegueWithIdentifier:@"2" sender:indexPath];

                    break;

                case 1:

                    [self performSegueWithIdentifier:@"3" sender:indexPath];

                    break;

                    

                default:

                    break;

            }

            

        }else

            [self performSegueWithIdentifier:@"7" sender:indexPath];

        

    }

    //cell  头顶距离

    -(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{

       

        return 20;

    }

     

    //tableView 最后的颜色

    //-(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{

    ////    UIView *view=[[UITableView alloc]init];

    //    UIView *view=[[UITableView alloc]initWithFrame:CGRectMake(0, 0, 20, 100)];

    //    view.backgroundColor=[UIColor lightGrayColor];

    //    return view;

    //}

    -(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{

        return 20;

    }

     ps:自定义cell要给它创建一个UITableViewCell , cell中要实现方法的 可以直接拖到当前控制器

  • 相关阅读:
    SiteMap Editor for Microsoft Dynamics CRM 2011 使用说明
    Microsoft Dynamics CRM 2011 如何导入组织
    SQL server 2008数据库的备份与还原(转)
    css列表
    css栅格
    css-排版
    类的操作
    事件的委派
    正则验证手机号和电子邮件
    div跟随鼠标移动
  • 原文地址:https://www.cnblogs.com/onlyYura/p/4188926.html
Copyright © 2020-2023  润新知