• 关于 UITableViewCell


    //最先进的是这个  返回一共有多少行!
    - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
    {
        NSLog(@"111");
        tableView.contentInset = UIEdgeInsetsMake(0, 0, -144, 0);
        //AppDelegate为一个代理类。
        AppDelegate *app = [[UIApplication sharedApplication]delegate];
        int count = [app.module.arrlist count];
        if (count > 4) 
        {
            return count+2;
        }else 
        {
            return count;
        }
        
    }
    
    //然后就进到了这里面。   这次返回的是每一行的高度 
    - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
    {
        NSLog(@"222");
        return 55;
    }
    
    
    
    //这是关键一步。只要有滑动,如果超过了它的范围,它就会一直调用这个方法
    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {
        NSLog(@"333");
         AppDelegate *app = [[UIApplication sharedApplication]delegate];
           if(indexPath.row < app.module.arrlist.count)
        { 
            UITableViewCell *cell = [[UITableViewCell alloc]initWithFrame:CGRectZero];
            cell.frame = CGRectMake(0, 0, 320, 50);
            UILabel *label = [[UILabel alloc]init];
            label.frame = CGRectMake(0, 0, 320, 30);
            label.text = @"aaaaaa";
            [cell.contentView addSubview:label];
    
            label.text = [[app.module.arrlist objectAtIndex:indexPath.row]objectForKey:@"Name"];
           return cell;
        }
        else if(indexPath.row == app.module.arrlist.count)
        {
            UITableViewCell *cell1 = [[UITableViewCell alloc]initWithFrame:CGRectZero];
            cell1.frame = CGRectMake(0, 0, 320, 50);
            UILabel *label1 = [[UILabel alloc]init];
            label1.frame = CGRectMake(0, 0, 320, 30);
            label1.text = @"刷新";
            [cell1.contentView addSubview:label1];
            return cell1;
        }
        else
        {
            //[self waitView:YES];
            NSLog(@"~~~~~~~~~~~~~~");
            [self waitView:YES];
            //NSLog(@"%@",[testarray objectAtIndex:0]);
            UITableViewCell *cell1 = [[UITableViewCell alloc]initWithFrame:CGRectZero];
            cell1.frame = CGRectMake(0, 0, 320, 50);
            UILabel *label1 = [[UILabel alloc]init];
            label1.frame = CGRectMake(0, 0, 320, 30);
            label1.text = @"刷新~";
            [cell1.contentView addSubview:label1];
            
            //当数据到达末尾的时候,这时候就需要重新为加载数据了。加载前的行数为10,第一次加载后它的行数恋为了22,这样它就会一直循环下去
            int i ;
            for(i =0; i<10; i++)
            {
               [app.module.arrlist addObject:app.module.arrinfo];
            }
            
            NSLog(@"count%d",app.module.arrlist.count);
            [tbv reloadData];
            [self stop];
            return cell1;
        }
        //return tablecellv;
    }
    
    
    //点击单个table view 的时候为触发这个方法
    -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
    {
        NSLog(@"4444");
        [tableView deselectRowAtIndexPath:indexPath animated:NO];
    }
    -(void)xmlarraytest
    {
        AppDelegate *app = [[UIApplication sharedApplication]delegate];
        app.module.arrinfo = [NSMutableDictionary dictionary];
        app.module.arrlist = [NSMutableArray array]; 
    
        //[app.module.arrinfo setObject:@"TTTTTT" forKey:@"key"];
        
        NSMutableDictionary *dic1 = [[NSMutableDictionary alloc] initWithObjectsAndKeys:@"Michael", @"Name", @"26", @"Age", nil];  
       
        NSMutableArray *array = [[NSMutableArray alloc] initWithObjects:dic1, dic1, dic1, dic1, dic1,dic1,dic1,dic1,dic1,dic1,nil]; 
        app.module.arrinfo = dic1;
        app.module.arrlist = array;
        [app.module.arrlist addObject:app.module.arrinfo];
        NSLog(@"qq%d",app.module.arrlist.count);
        NSLog(@"xxx%@",[app.module.arrlist objectAtIndex:0]);
        NSLog(@"%@",[app.module.arrinfo objectForKey:@"Name"]);
        NSLog(@"app:%@",[[app.module.arrlist objectAtIndex:0]objectForKey:@"Name"]);
    
    }
      //圆圈动画
        _aiView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
        //[aiView setBackgroundColor:[UIColor grayColor]];
        _aiView.frame = CGRectMake([UIScreen mainScreen].bounds.size.width/2 - 45/2, [UIScreen mainScreen].bounds.size.height/2 - 45/2+120, 45, 45);
        _aiView.hidesWhenStopped = YES;
        [self.view addSubview:[_aiView autorelease]];
        [_aiView stopAnimating];
    //圈圈动画控制
    -(void)waitView:(BOOL)want2Show
    {
        if (want2Show) {
            [self.view bringSubviewToFront:_clickMask];
            [self.view bringSubviewToFront:_aiView];
            [_clickMask setHidden:NO];
            [_aiView startAnimating];
        }else {
            [_clickMask setHidden:YES];
            [_aiView stopAnimating];
        }
    }
    //调用~
    [self waitView:YES];
  • 相关阅读:
    队列简单题
    排序篇(c++/c实现)
    天河计算机0.5
    BZOJ2301/LG2522 「HAOI2011」Problem B 莫比乌斯反演 数论分块
    BZOJ1391/LG4177 「CEOI2008」order 最大权闭合子图
    BZOJ2007/LG2046 「NOI2010」海拔 平面图最小割转对偶图最短路
    BZOJ1001/LG4001 「ICPC Beijing2006」狼抓兔子 平面图最小割转对偶图最短路
    BZOJ2339/LG3214 「HNOI2011」 卡农 组合数学
    LG1840 Color the Axis 线段树
    LG5239 回望京都 组合数+暴力
  • 原文地址:https://www.cnblogs.com/qingjoin/p/2632159.html
Copyright © 2020-2023  润新知