ich einen einfacheren Weg, dies zu tun, indem Sie gefunden einer von Apples Proben:
- (UITableViewCell *)tableViewCellWithReuseIdentifier:(NSString *)identifier {
/*
Create an instance of UITableViewCell and add tagged subviews for the name, local time, and quarter image of the time zone.
*/
UITableViewCell *cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier] autorelease];
/*
Create labels for the text fields; set the highlight color so that when the cell is selected it changes appropriately.
*/
UILabel *label;
CGRect rect;
// Create a label for the time zone name.
rect = CGRectMake(LEFT_COLUMN_OFFSET, (ROW_HEIGHT - LABEL_HEIGHT)/2.0, LEFT_COLUMN_WIDTH, LABEL_HEIGHT);
label = [[UILabel alloc] initWithFrame:rect];
label.tag = NAME_TAG;
label.font = [UIFont boldSystemFontOfSize:MAIN_FONT_SIZE];
label.adjustsFontSizeToFitWidth = YES;
[cell.contentView addSubview:label];
label.highlightedTextColor = [UIColor whiteColor];
[label release];
// Create a label for the time.
rect = CGRectMake(MIDDLE_COLUMN_OFFSET, (ROW_HEIGHT - LABEL_HEIGHT)/2.0, MIDDLE_COLUMN_WIDTH, LABEL_HEIGHT);
label = [[UILabel alloc] initWithFrame:rect];
label.tag = TIME_TAG;
label.font = [UIFont systemFontOfSize:MAIN_FONT_SIZE];
label.textAlignment = UITextAlignmentRight;
[cell.contentView addSubview:label];
label.highlightedTextColor = [UIColor whiteColor];
[label release];
// Create an image view for the quarter image.
rect = CGRectMake(RIGHT_COLUMN_OFFSET, (ROW_HEIGHT - IMAGE_SIDE)/2.0, IMAGE_SIDE, IMAGE_SIDE);
UIImageView *imageView = [[UIImageView alloc] initWithFrame:rect];
imageView.tag = IMAGE_TAG;
[cell.contentView addSubview:imageView];
[imageView release];
return cell;
}
Ich weiß, es ist eine alte Frage, aber können Sie den Apfel Beispiel für mich verknüpfen? – Justin
@Juzzz: Ich weiß, dass diese Antwort verspätet ist, aber falls jemand anderes diese Frage findet: https://developer.apple.com/library/ios/#samplecode/TableViewSuite/Introduction/Intro.html#//apple_ref/doc/ uid/DTS40007318 – alokoko
@alokoko danke für die Verknüpfung, habe ich den Kommentar nicht bemerkt. – Justin