Sportica   Sportica

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

 

 

 

 

 

posted @ 2012-08-10 16:45  qingjoin  阅读(623)  评论(0编辑  收藏  举报
  Sportica