2016-10-13 63 views
0

我正在使用自定義單元格。此處我加載兩個圖像和四個標籤。 TableView滾動不順暢。這裏是我的代碼。UITableView滾動與ios中的自定義表格單元格不平滑

 static NSString *simpleTableIdentifier = @"SimpleTableCell"; 

     CustomCell *cell = (CustomCell *)[tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier]; 
     if (cell == nil) 
     { 
      NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"CustomCellSixPlus" owner:self options:nil]; 
      cell = [nib objectAtIndex:0]; 
     } 
     cell.cellButtonOutlet.tag = indexPath.row; 
     [cell.cellButtonOutlet addTarget:self action:@selector(yourButtonClicked:) forControlEvents:UIControlEventTouchUpInside]; 


     NSManagedObjectModel *device = [self.devices objectAtIndex:indexPath.row]; 


     long int index1 = [languageCode indexOfObject: [NSString stringWithFormat:@"%@",[device valueForKey:@"sourceLang"]]]; 
     long int index2 = [languageCode indexOfObject: [NSString stringWithFormat:@"%@",[device valueForKey:@"destinationLang"]]]; 


     cell.nameLabel1.text = [languageName objectAtIndex:index1]; 
     cell.nameLabel2.text = [languageName objectAtIndex:index2]; 

     cell.nameLabel3.text = [NSString stringWithFormat:@"%@",[device valueForKey:@"sourceText"]]; 
     cell.nameLabel4.text = [NSString stringWithFormat:@"%@",[device valueForKey:@"transilateText"]]; 

     cell.sourceFlagImageview.image = [UIImage imageNamed:[languageName objectAtIndex:index1]]; 
     cell.translateFlagImageview.image = [UIImage imageNamed:[languageName objectAtIndex:index2]]; 

     return cell; 

問題,通過增加細胞高度代碼

+2

嘗試在背景隊列中設置圖像,而不是在主線程中設置圖像 –

回答

1

註釋以下行,然後再試一次解決:

long int index1 = [languageCode indexOfObject: [NSString stringWithFormat:@"%@",[device valueForKey:@"sourceLang"]]]; 
long int index2 = [languageCode indexOfObject: [NSString stringWithFormat:@"%@",[device valueForKey:@"destinationLang"]]]; 

cell.sourceFlagImageview.image = [UIImage imageNamed:[languageName objectAtIndex:index1]]; 
cell.translateFlagImageview.image = [UIImage imageNamed:[languageName objectAtIndex:index2]]; 

如果它會正常工作,那麼你需要指定在後臺排隊

圖片
+0

不,同樣..但是問題解決了。通過增加細胞高度解決。 – Saad

相關問題