Je travaille sur une cellule personnalisée dans uitableview et j'essaie d'ajouter des uilabels dans la cellule mais je ne peux pas y placer de texte. Voici comment je suis en train d'ajouter la cellule et aussi comment j'ajoute le texteAjout de UILabel à l'UITableViewCell personnalisé
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *MyIdentifier = @"MyIdentifier";
customCell *cell = (customCell *)[tableView dequeueReusableCellWithIdentifier:MyIdentifier];
if (cell == nil) {
cell = [[[customCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:MyIdentifier] autorelease];
cell.imageView.image = [UIImage imageNamed:@"iTeam.png"];
}
cell.orangeText1 = @"Mikes Bar";
cell.orangeText1 = @"4.3 mi northeast";
cell.whiteText1 = @"Level";
cell.whiteText1 = @"Freshman";
return cell;
}
Ma classe cellulaire personnalisée:
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
if ((self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])) {
// Initialization code
//
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 60)];
view.backgroundColor = [UIColor blackColor];
view.opaque = YES;
self.backgroundView = view;
[view release];
cellImage = [[UIImageView alloc] init];
myLabel *lblview = [[myLabel alloc] initWithFrame:CGRectMake(self.imageView.frame.size.width+10, 0, 320, 20) OrangeText:orangeText1 WhiteText:whiteText1];
[self.contentView addSubview:lblview];
[lblview release];
lblview = [[myLabel alloc] initWithFrame:CGRectMake(self.imageView.frame.size.width+10, 22, 320, 20) OrangeText:orangeText2 WhiteText:whiteText2];
[self.contentView addSubview:lblview];
[lblview release];
UIImage *image = [UIImage imageNamed:@"acessory.png"];
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
CGRect frame = CGRectMake(0.0, 0.0, image.size.width, image.size.height);
button.frame = frame;
[button setBackgroundImage:image forState:UIControlStateNormal];
button.backgroundColor = [UIColor clearColor];
self.accessoryView = button;
[button release];
UIImageView *imagevw = [[UIImageView alloc] initWithFrame:CGRectMake(0, 50, 320, 8)];
imagevw.image = [UIImage imageNamed:@"linee.png"];
[self addSubview:imagevw];
[imagevw release];
}
return self;
}
Tout le reste est fonctionne bien, mais je ne reçois pas le texte sur l'étiquette. L'étiquette elle-même est appelée depuis une autre classe uiview.
Merci
je suis allé avec vos recommandations .. merci de répondre – pankaj