How to set the attributes of cell progamatically without using nib file ?
Posted
by srikanth rongali
on Stack Overflow
See other posts from Stack Overflow
or by srikanth rongali
Published on 2010-04-16T06:28:28Z
Indexed on
2010/04/16
6:33 UTC
Read the original article
Hit count: 135
- (void)viewDidLoad { [super viewDidLoad];
// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
self.title = @"Library";
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Close" style:UIBarButtonItemStyleBordered target:self action:@selector(close:)];
self.tableView.rowHeight = 80;
}
-(void)close:(id)sender
{
//
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{ cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
UILabel *dateLabel = [[UILabel alloc]init];
dateLabel.frame = CGRectMake(85.0f, 6.0f, 200.0f, 20.0f);
dateLabel.tag = tag1;
[cell setAccessoryType:UITableViewCellAccessoryDisclosureIndicator];
cell.contentView.frame = CGRectMake(0.0f, 0.0f, 320.0f, 80.0f);
[cell.contentView addSubview:dateLabel];
[dateLabel release];
}
// Set up the cell...
//[(UILabel *)[cell viewWithTag:tag1] setText:@"Date"];
cell.textLabel.text = @"Date";
return cell;
}
But the control is not entering into the tableView: method. So I could not see any label in my table. How can I make this ? Thank You
© Stack Overflow or respective owner