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];

  • 相关阅读:
    2407: C语言习题 整数转换成字符串
    2484: 字母图形
    1658: Easier Done Than Said?
    Easier Done Than Said?(应用到的知识)
    1653: Champion of the Swordsmanship
    1614: 五位以内的对称素数
    1612: 最小公倍数
    $ vs $()
    数学
    计算机科学与技术课程
  • 原文地址:https://www.cnblogs.com/god-love-yao/p/4276425.html
Copyright © 2011-2022 走看看