2011-11-22 6 views
2

사용자 정의 셀에 UItableview가 있습니다. 사용자 정의 셀에는 많은 세부 사항이있는 이미지가 있습니다. 하지만 내 스크롤이 급격합니다. 스크롤링 성능을 어떻게 향상시킬 수 있습니까?표보기에서 스크롤링 성능 향상

나는 여기에 내 코드를 게시하고있다 : if 문이 때마다 실행되지 않도록 당신은 == 셀에서 전무를

cell.selectionStyle = UITableViewCellSelectionStyleNone; 
cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton; 

을 넣을 수

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
    {  
     NSUInteger row = [indexPath row]; 



     Theo1AppDelegate *iDelegate = [[UIApplication sharedApplication] delegate]; 

     static NSString * ListitemCellIdentifier = @"ListitemCellIdentifier"; 
     ListItemCell * cell = (ListItemCell *)[tableView dequeueReusableCellWithIdentifier:ListitemCellIdentifier]; 

      if(cell == nil ) 
      { 
       [[NSBundle mainBundle] loadNibNamed:@"ListItemCell" owner:self options:nil]; 

       cell = self.mCell; 
       self.mCell = nil; 
      } 



      cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton; 
      SampleObject * p = nil; 
p = [self.mSelections objectAtIndex:row ]; 
      cell.tag = row; 

      cell.mPropertyLabel.text = [p Address]; 
      NSString * comboStr1 = [NSString stringWithFormat:@"%d ", (int)[p.mBeds doubleValue] ]; 

      cell.mBedBathSqftLabel.text = comboStr1; 

      NSNumber * number = [NSNumber numberWithDouble:[p.mBaths doubleValue]]; 
      NSString * string = [number stringValue]; 

      int le = [string length]; 
      if(le == 1) 
      { 
       cell.mBathLabel.frame = CGRectMake(590, 60, 30, 23); 
       cell.mBathLabel.text = string; 
      } 
      else if(le == 3) 
      { 
       cell.mBathLabel.frame = CGRectMake(590, 60, 35, 23); 
       cell.mBathLabel.text = string; 
      } 
      else if(le == 4) 
      { 
       cell.mBathLabel.frame = CGRectMake(590, 60, 40, 23); 
       cell.mBathLabel.text = string; 
      } 


      int sqftval = [p.mLivingArea intValue]; 

      NSString * sqft = @""; 
      if(sqftval == 0) 
      { 

       cell.mSqftLabel.text [email protected]"NA"; 
      } 
      else 
      { 
       NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init]; 
       [numberFormatter setNumberStyle: NSNumberFormatterDecimalStyle]; 
       NSString * isqft = [numberFormatter stringFromNumber:[NSNumber numberWithInt:sqftval] ]; 
       sqft = [NSString stringWithFormat:@"%@", isqft]; 
       cell.mSqftLabel.text = sqft; 
       [numberFormatter release]; 
      } 


      NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init]; 
      [numberFormatter setNumberStyle: NSNumberFormatterCurrencyStyle]; 
      NSString * pStr = [numberFormatter stringFromNumber:p.mPrice]; 
      NSString * pStr1 =[pStr substringToIndex:[pStr length]- 3 ]; 
      cell.mPriceLabel.text = pStr1; 
      [numberFormatter release]; 



      NSString * cross = @""; 
      if(p.mCrossStreet != nil) 
       cross = [NSString stringWithFormat:@"%@", p.mCrossStreet]; 
      cell.mCrossStLabel.text = cross; 
      if([p.mParkingTotal intValue] == 0) 
      { 
       cell.mParkingLabel.text = @"NA"; 
      } 
      else 
      { 
       NSString * parkingStr = [NSString stringWithFormat:@"%d", [p.mParkingTotal intValue] ]; 
       cell.mParkingLabel.text = parkingStr; 
      } 



      NSString * Notes = @""; 
      if(p.mRemarks != nil) 
       Notes = [NSString stringWithFormat:@"%@", p.mRemarks]; 
       cell.c.editable = FALSE; 

      int len = [Notes length]; 
      if (len < 240) 
      { 
       cell.mNotes.text = Notes; 

      } 
      else 
      { 
       NSString * curString = [agentNotes substringToIndex:240]; 
       curString = [curString stringByAppendingString:@"...."]; 
       cell.mNotes.text= curString; 
      } 


       cell.selectionStyle = UITableViewCellSelectionStyleNone; 

      cell.mID = p.mID; 

      return cell; 
     } 
+0

사용자 정의 셀의 코드를 게시하여 지연 현상이 무엇인지 알 수 있도록하십시오. –

답변

1

. mBathLabel의 프레임을 변경하기 위해 문자열 길이를 점검하는 시점이 보이지 않습니다. 그리고 2 NSNumberFormatter은 클래스의 속성으로 만들 수 있으므로 매번 할당/초기화/해제 될 필요가 없습니다.

+0

에릭에게 감사드립니다. 나는 이것을 시도 할 것이다. 정말 고맙습니다. – Sharme