Tuesday, July 24, 2012

Passing data from UItableviewController to UItableViewcell in ios


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"MyCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {        
    cell = [[CustomCell alloc] initWithStyle:<style enum value> reuseIdentifier:reuseIdentifier string:urlstring]
    //cell.mystring = self.mystring;
}
// customize your image and your labels here with rects here

UIImageView *image = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"yourimage.png"]];
    [cell.contentView addSubview:image];
UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(your rect here)];
[cell.contentView addSubview:label];
return cell;
}

No comments:

Post a Comment