2
我正在使用自定義單元格的UItableview。自定義單元格具有很多細節的圖像。但我的滾動是跳動。我如何提高滾動性能?改善表格視圖中的滾動性能
我在這裏發佈我的代碼:
-(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;
}
請張貼您的自定義單元的代碼,以便能夠說明是什麼使它變得遲鈍。 –