2014-09-08 6 views
0

У меня есть UITableView, добавленный в UIView, когда данные возвращаются из базы данных, я передаю данные в NSMutableArray. Когда ячейки получают визуализацию, я создаю UIView внутри ячейки с данными, выводимыми в этот UIView. Теперь ячейки получают визуализацию с помощью UIViews, и я вижу, что отображаются UIViews. Но полоса прокрутки не работает, так как я не могу прокрутить вниз, чтобы увидеть другие ячейки, которые содержат UIViews с данными.IOS, UITabelView не прокручивается

Код:

 tableViewThreads = [[UITableView alloc] initWithFrame:CGRectMake(0, 104, screenRect.size.width, 336)]; 
     tableViewThreads.delegate = self; 
     tableViewThreads.dataSource = self; 
     tableViewThreads.bounces = YES; 
     tableViewThreads.separatorStyle = UITableViewCellSeparatorStyleNone; 
     [viewTopThread addSubview:tableViewThreads]; 

     tableViewThreads.userInteractionEnabled = YES; 
     [self.view bringSubviewToFront:tableViewThreads]; 



     -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 
      if(tableViewThreads == tableView){ 
      return [threadsArray count]; 
      } 

      return 0; 
     } 

     -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 
      static NSString *cellIdentifier = @"cell"; 

      UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier]; 

      if (cell == nil) 
      { 
      cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellIdentifier]; 
      } 
      if(tableViewThreads == tableView){ 
      ThreadInfo *threadInfo = (ThreadInfo*)[self.threadsArray objectAtIndex:indexPath.row]; 

      [cell.contentView addSubview:[self setupThreadItem:threadInfo]]; 

      //[cell.textLabel setText:tweet]; 
      //[cell.detailTextLabel setText:@"via Codigator"]; 
      } 

      return cell; 
     } 

     - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath 
     { 
      if(tableViewThreads == tableView){ 

      return 122; 

      } 

      return 0; 
     } 


-(void)renderThreadInfo:(NSDictionary*)dic{ 

       NSDictionary *thread = [dic objectForKey:@"thread"]; 

       int t_ID; 
       int t_U_ID; 
       int t_C_ID; 
       NSString *t_Name; 
       NSString *t_Description; 
       NSDate *t_Created; 
       int t_Flagged; 
       int t_Rated; 

       for(NSDictionary *dict in thread) 
       { 
       if((NSNull *)[dict objectForKey:@"T_ID"] != [NSNull null]){ 
        t_ID = [[dict objectForKey:@"T_ID"] intValue]; 
       } 
       if((NSNull *)[dict objectForKey:@"T_U_ID"] != [NSNull null]){ 
        t_U_ID = [[dict objectForKey:@"T_U_ID"] intValue]; 
       } 
       if((NSNull *)[dict objectForKey:@"T_C_ID"] != [NSNull null]){ 
        t_C_ID = [[dict objectForKey:@"T_C_ID"] intValue]; 
       } 
       if((NSNull *)[dict objectForKey:@"T_Name"] != [NSNull null]){ 
        t_Name = [dict objectForKey:@"T_Name"]; 
       } 
       if((NSNull *)[dict objectForKey:@"T_Description"] != [NSNull null]){ 
        t_Description = [dict objectForKey:@"T_Description"]; 
       } 
       if((NSNull *)[dict objectForKey:@"T_Created"] != [NSNull null]){ 
        NSString *timestampString = [dict objectForKey:@"T_Created"]; 
        double timestampDate = [timestampString doubleValue]; 
        t_Created = [NSDate dateWithTimeIntervalSince1970:timestampDate]; 
       } 
       if((NSNull *)[dict objectForKey:@"T_Flagged"] != [NSNull null]){ 
        t_Flagged = [[dict objectForKey:@"T_Flagged"] intValue]; 
       } 
       if((NSNull *)[dict objectForKey:@"T_Rated"] != [NSNull null]){ 
        t_Rated = [[dict objectForKey:@"T_Rated"] intValue]; 
       } 

       ThreadInfo *threadObj = [ThreadInfo new]; 
       threadObj.iD = t_ID; 
       threadObj.userId = t_U_ID; 
       threadObj.catId = t_C_ID; 
       threadObj.name = t_Name; 
       threadObj.description = t_Description; 
       threadObj.timeStampCreated = t_Created; 
       threadObj.flagged = t_Flagged; 
       threadObj.rated = t_Rated; 

       [threadsArray addObject:threadObj]; 

       [tableViewThreads reloadData]; 

       } 

      } 
+0

Подсказка: Я держу пари, что у вас есть авто-макет включен ... – Stonz2

+0

@ Stonz2, авто-макет? – redoc01

ответ

0

Я добавлял UITableView к неправильному UIView.

Должно быть:

[self.viewCreateThread addSubview:tableViewThreads]; 

Но когда я теперь прокручивать сбои приложения, я раскрою еще один вопрос.

Благодаря