dynamic row height

Posted by Prasanna Venkatesh on Stack Overflow See other posts from Stack Overflow or by Prasanna Venkatesh
Published on 2011-01-11T17:40:15Z Indexed on 2011/01/11 17:53 UTC
Read the original article Hit count: 292

Filed under:
|
static NSString *CellIdentifier = @"Cell";

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@""];
if (cell == nil) {
    cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault      reuseIdentifier:CellIdentifier] autorelease];
}
//cell.backgroundView = [[[CustomCell alloc] init] autorelease];
cell.selectedBackgroundView = [[[CustomCell alloc] init] autorelease];

// At end of function, right before return cell:
cell.textLabel.backgroundColor = [UIColor clearColor];


// Configure the cell.
UILabel *myLabel1 = [[UILabel alloc] initWithFrame:CGRectMake(-30, 3, 300, 22)];
UILabel *myLabel2 = [[UILabel alloc] initWithFrame:CGRectMake(10, 22, 310, 200)];
UILabel *myLabel3 = [[UILabel alloc] initWithFrame:CGRectMake(0, 170, 300, 20)];

Book *aBook = [appDelegate.books objectAtIndex:indexPath.row];


    myLabel1.text=aBook.title;
    myLabel2.text=aBook.description;
    myLabel3.text=aBook.pubDate;

    NSString *desc = aBook.description;
    if ([desc isEqualToString:nil]) {
        NSLog(@"nullll lll ");
    }


//myLabel2.textAlignment=UITextAlignmentCenter;              
myLabel2.numberOfLines=5;   
myLabel2.textColor=[UIColor blueColor];
myLabel2.lineBreakMode=UILineBreakModeWordWrap;
myLabel2.font=[UIFont systemFontOfSize:14];
myLabel3.numberOfLines=1;
myLabel1.numberOfLines=1;
myLabel1.textColor=[UIColor redColor];
myLabel1.font=[UIFont systemFontOfSize:20];
myLabel1.shadowColor=[UIColor redColor];
myLabel1.backgroundColor=[UIColor grayColor];
        [cell.contentView addSubview:myLabel1];
        [cell.contentView addSubview:myLabel2];
        [cell.contentView addSubview:myLabel3];

hi guys! i have this following code, i want to display this from xml file. now its working but static row height. if the xml file dont have data then it leaves it as blank. so i want to change row height according to the data i provide using the mylabel1,2,3.text

© Stack Overflow or respective owner

Related posts about iphone

Related posts about uitableview