Chinaunix首页 | 论坛 | 博客
  • 博客访问: 90631
  • 博文数量: 22
  • 博客积分: 486
  • 博客等级: 下士
  • 技术积分: 262
  • 用 户 组: 普通用户
  • 注册时间: 2012-03-07 19:26
文章分类

全部博文(22)

文章存档

2012年(22)

我的朋友

分类: 嵌入式

2012-08-10 16:50:53


点击(此处)折叠或打开

  1. //最先进的是这个 返回一共有多少行!
  2. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  3. {
  4.     NSLog(@"111");
  5.     tableView.contentInset = UIEdgeInsetsMake(0, 0, -144, 0);
  6.     //AppDelegate为一个代理类。
  7.     AppDelegate *app = [[UIApplication sharedApplication]delegate];
  8.     int count = [app.module.arrlist count];
  9.     if (count > 4)
  10.     {
  11.         return count+2;
  12.     }else
  13.     {
  14.         return count;
  15.     }
  16.     
  17. }

  18. //然后就进到了这里面。 这次返回的是每一行的高度
  19. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
  20. {
  21.     NSLog(@"222");
  22.     return 55;
  23. }



  24. //这是关键一步。只要有滑动,如果超过了它的范围,它就会一直调用这个方法
  25. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  26. {
  27.     NSLog(@"333");
  28.      AppDelegate *app = [[UIApplication sharedApplication]delegate];
  29.        if(indexPath.row < app.module.arrlist.count)
  30.     {
  31.         UITableViewCell *cell = [[UITableViewCell alloc]initWithFrame:CGRectZero];
  32.         cell.frame = CGRectMake(0, 0, 320, 50);
  33.         UILabel *label = [[UILabel alloc]init];
  34.         label.frame = CGRectMake(0, 0, 320, 30);
  35.         label.text = @"aaaaaa";
  36.         [cell.contentView addSubview:label];

  37.         label.text = [[app.module.arrlist objectAtIndex:indexPath.row]objectForKey:@"Name"];
  38.        return cell;
  39.     }
  40.     else if(indexPath.row == app.module.arrlist.count)
  41.     {
  42.         UITableViewCell *cell1 = [[UITableViewCell alloc]initWithFrame:CGRectZero];
  43.         cell1.frame = CGRectMake(0, 0, 320, 50);
  44.         UILabel *label1 = [[UILabel alloc]init];
  45.         label1.frame = CGRectMake(0, 0, 320, 30);
  46.         label1.text = @"刷新";
  47.         [cell1.contentView addSubview:label1];
  48.         return cell1;
  49.     }
  50.     else
  51.     {
  52.         //[self waitView:YES];
  53.         NSLog(@"~~~~~~~~~~~~~~");
  54.         [self waitView:YES];
  55.         //NSLog(@"%@",[testarray objectAtIndex:0]);
  56.         UITableViewCell *cell1 = [[UITableViewCell alloc]initWithFrame:CGRectZero];
  57.         cell1.frame = CGRectMake(0, 0, 320, 50);
  58.         UILabel *label1 = [[UILabel alloc]init];
  59.         label1.frame = CGRectMake(0, 0, 320, 30);
  60.         label1.text = @"刷新~";
  61.         [cell1.contentView addSubview:label1];
  62.         
  63.         //当数据到达末尾的时候,这时候就需要重新为加载数据了。加载前的行数为10,第一次加载后它的行数恋为了22,这样它就会一直循环下去
  64.         int i ;
  65.         for(i =0; i<10; i++)
  66.         {
  67.            [app.module.arrlist addObject:app.module.arrinfo];
  68.         }
  69.         
  70.         NSLog(@"count%d",app.module.arrlist.count);
  71.         [tbv reloadData];
  72.         [self stop];
  73.         return cell1;
  74.     }
  75.     //return tablecellv;
  76. }


  77. //点击单个table view 的时候为触发这个方法
  78. -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  79. {
  80.     NSLog(@"4444");
  81.     [tableView deselectRowAtIndexPath:indexPath animated:NO];
  82. }

  83.  
  84.  

  85.   //圆圈动画
  86.     _aiView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
  87.     //[aiView setBackgroundColor:[UIColor grayColor]];
  88.     _aiView.frame = CGRectMake([UIScreen mainScreen].bounds.size.width/2 - 45/2, [UIScreen mainScreen].bounds.size.height/2 - 45/2+120, 45, 45);
  89.     _aiView.hidesWhenStopped = YES;
  90.     [self.view addSubview:[_aiView autorelease]];
  91.     [_aiView stopAnimating];


  92. //圈圈动画控制
  93. -(void)waitView:(BOOL)want2Show
  94. {
  95.     if (want2Show) {
  96.         [self.view bringSubviewToFront:_clickMask];
  97.         [self.view bringSubviewToFront:_aiView];
  98.         [_clickMask setHidden:NO];
  99.         [_aiView startAnimating];
  100.     }else {
  101.         [_clickMask setHidden:YES];
  102.         [_aiView stopAnimating];
  103.     }
  104. }

  105.  
  106. //调用~
  107. [self waitView:YES];

阅读(1587) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~