Я использовал этот подход в игре, я развиваюсь.
Подкласс UITableViewCell, затем вы добавляете UIImageView и UILabel в ячейку программно. это дает вам отличный способ настроить внешний вид вашей камеры.
- (id)initWithFrame:(CGRect)frame reuseIdentifier:(NSString *)reuseIdentifier {
if (self = [super initWithFrame:frame reuseIdentifier:reuseIdentifier]) {
// Initialization code
headerLabel = [[UILabel alloc]init];
headerLabel.textAlignment = UITextAlignmentLeft;
imageV = [[UIImageView alloc] init];
descriptionLabel.font = [UIFont fontWithName:@"Marker Felt" size:14];
descriptionLabel = [[UILabel alloc]init];
descriptionLabel.textAlignment = UITextAlignmentLeft;
descriptionLabel.font = [UIFont fontWithName:@"Marker Felt" size:11];
descriptionLabel.lineBreakMode = UILineBreakModeWordWrap;
descriptionLabel.numberOfLines = 0;
[self.contentView addSubview:headerLabel];
[self.contentView addSubview:descriptionLabel];
[self.contentView addSubview:imageV];
}
return self;
}
- (void)layoutSubviews {
[super layoutSubviews];
CGRect contentRect = self.contentView.bounds;
CGFloat boundsX = contentRect.origin.x;
CGRect frame;
frame= CGRectMake(boundsX+60 ,3, 200, 15);
headerLabel.frame = frame;
frame= CGRectMake(boundsX+60 ,18, 260, 39);
descriptionLabel.frame = frame;
frame= CGRectMake(boundsX+3 , 3, 54, 54);
imageV.frame = frame;
}
Кроме того, вам придется изменить метод в классе UITableView:
// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
NSString *CellIdentifier = @"Cell";
AchievementCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[AchievementCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
}
[cell returnCellAtIndex:indexPath.row];
[cell returnImageAtIndex:indexPath.row];
return cell;
}
Не стесняйтесь задавать больше вопросов относительно кода :)
Я объявляю ячейку ... Это всего лишь часть кода .... – Cintu