birçok kullanım ait subviews olarak etiketleri ekleme tekniği Hücre ve belki de hücrelerin yeniden kullanılmasıyla beklenmedik sonuçlara ulaşırsınız. Apple zaten her açıdan özelleştirilebilen şablonlar sunuyor. Sizin durumunuzda, özel hücreler kullanmadan ve etiket eklemeden, UITableViewCellStyleValue2
şablonunu kullanacağım, mevcut etiketlerle ve , cell.detailTextLabel
ve cell.accessoryView
gibi aksesuarlarla birlikte oynayabiliyorsunuz, ara yüzünüze daha fazla veya daha az benzeyen bu kod parçasına bakın:
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *CellID = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellID];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue2
reuseIdentifier:CellIdentifier] autorelease];
}
cell.textLabel.contentMode=UIViewContentModeScaleToFill;
cell.textLabel.lineBreakMode = UILineBreakModeWordWrap;
cell.textLabel.baselineAdjustment=UIBaselineAdjustmentAlignCenters;
cell.textLabel.textAlignment=UITextAlignmentCenter;
cell.textLabel.font=[UIFont boldSystemFontOfSize:22];
cell.textLabel.textColor=[UIColor lightGrayColor];
cell.detailTextLabel.contentMode=UIViewContentModeScaleToFill;
cell.detailTextLabel.lineBreakMode = UILineBreakModeWordWrap;
cell.detailTextLabel.baselineAdjustment=UIBaselineAdjustmentAlignCenters;
cell.detailTextLabel.textAlignment=UITextAlignmentLeft;
cell.detailTextLabel.font=[UIFont boldSystemFontOfSize:23];
cell.detailTextLabel.textColor=[UIColor blackColor];
[email protected]"Tel.:";
[email protected]"+3912345678";
UIImageView *imageView = [[UIImageView alloc] initWithImage:
[UIImage imageNamed:@"phone.png"]];
cell.accessoryView = imageView;
[imageView release];
return cell;
}
Bu yardımcı olur umarım.
Her zaman UITableViewCell ve buna iki UILabels alt sınıf. – tilo