zoukankan      html  css  js  c++  java
  • tabview

     

    /*------------------------以下为UITableViewDataSource代理方法------------------------*/

                                                                                            //加载loadView,之后先返回section,再返回row,在设置row高度,最后绘制cell

     

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

    {

        return [_aa count];

    }

     

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

    {

        static NSString *celID = @"cell";

        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:celID];

        if (cell==nil) {

            cell = [[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:celID] autorelease];

            UILabel *lable = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 600, 60)];

            lable.tag = 101;

            //lable.backgroundColor = [UIColor blueColor];

            [cell.contentView addSubview:lable];

            [lable release];

        }

        

        UILabel *lable = (UILabel*)[cell.contentView viewWithTag:101];

        lable.text = [self.aa objectAtIndex:indexPath.row];

        lable.textColor = [UIColor redColor];

        lable.font = [UIFont systemFontOfSize:28];

        lable.numberOfLines = 0;  

        

        

    //    cell.textLabel.text = [self.aa objectAtIndex:indexPath.row];

    //    cell.textLabel.textColor = [UIColor redColor];

    //    cell.textLabel.font = [UIFont systemFontOfSize:28];

    //    cell.textLabel.numberOfLines = 0;                   //  解除row的限制

        

        if (_path.row==indexPath.row) {

            cell.accessoryType =1;

                                                            //NSLog(@"当前的风格为----%d",cell.accessoryType);//这里不知道为什么有时候会是1,有时候会是0,感觉有点像交替的

        }else{

            cell.accessoryType =0;

        }

        NSLog(@"row:  %d",indexPath.row);

        return cell;

    }

     

    - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView

    {

        return 1;

    }

     

    /*------------------------以下为UITableView代理方法------------------------*/

    - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath          //设置row

    {

        NSString *text = [_aa objectAtIndex:indexPath.row];   //UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];//错误的写法

        CGSize size = [text sizeWithFont:[UIFont systemFontOfSize:28] constrainedToSize:CGSizeMake(768, 1024)];

        return size.height+36;

    }

     

     

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

    {

        NSLog(@"现在选中了row:  %d",indexPath.row);

        

        UITableViewCell *lastCell = [tableView cellForRowAtIndexPath:_path];

        lastCell.accessoryType = 0;

        

        UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];

        cell.accessoryType = 1;

        

        _path = [indexPath retain];

  • 相关阅读:
    jsp 生成验证码代码
    成为Java顶尖程序员 ,看这11本书就够了
    自动清除浏览器缓存-Cache Killer
    移动端-ios-上拉加载卡顿
    移动端-ios-点击阴影去除
    转--Android开发实践:使用Service还是Thread
    Android入门:Handler简介与实例
    Spring事务的隔离级别
    ThreadLocal的内存泄漏问题
    Spring 使用注解方式进行事务
  • 原文地址:https://www.cnblogs.com/god-love-yao/p/4276425.html
Copyright © 2011-2022 走看看