Skip to content

Instantly share code, notes, and snippets.

@romyilano
Created February 26, 2013 04:26
Show Gist options
  • Select an option

  • Save romyilano/5035868 to your computer and use it in GitHub Desktop.

Select an option

Save romyilano/5035868 to your computer and use it in GitHub Desktop.
Creating a UILabel without nib files in a custom uITableViewCell... apress.com pro iOS table views
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *cellIdentifier = @"cellIdentifier";
UITableVIewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if(cell == nil) {
cell = [[UITableVIewCell alloc] initWithStyle:UITableVIewCellStyleDefault resuseIdentifier:cellIdentifier];
// create a new label with the size we need
UILabel *myLabel = [[UILabel alloc] init];
myLabel.frame = CGRectMake(75, 10, 200, 25);
// set the label's tag value
myLabel.tag = 1020;
// add the new label to the content view
[cell.contentView addSubView:myLabel];
}
// configure the cell & custom content here
//
return cell;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment