Hi,
I am working on custom cell in uitableview and trying to add uilabels in the cell but not able to set text on it. Following is how i am trying to add the cell and also how i am adding the text
- (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;
}
My Custom cell class:
- (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;
}
Everything else is working fine but i am not getting the text on the label. The label itself is being called from another uiview class.
Thanks