How to renew cell in uitableview in ios
I'm a newbie. I use this code to create uitableview cell but when
reloadtable, image of these buttons is overload but all Labels is works
fine. I don't know why. How can i fix this error? Thanks much
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [_tableView
dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc]
initWithStyle:UITableViewCellStyleSubtitle
reuseIdentifier:CellIdentifier] autorelease];
}
UILabel *pricelabel = [[UILabel alloc]
initWithFrame:CGRectMake(80, 0, 80, 30)];
pricelabel.backgroundColor = [UIColor clearColor];
pricelabel.font = [UIFont fontWithName:@"Helvetica" size:16];
pricelabel.font = [UIFont boldSystemFontOfSize:16];
pricelabel.textColor = [UIColor darkGrayColor];
pricelabel.tag = 3000;
//pricelabel.hidden = YES;
pricelabel.textAlignment = NSTextAlignmentRight;
[cell.contentView addSubview: pricelabel];
[pricelabel release];
UIButton * market = [[UIButton alloc] init];
market= [UIButton buttonWithType:UIButtonTypeCustom];
if([sellingArray count]>0)
{
NSLog(@"sellingArray %@",sellingArray);
if([[sellingArray objectAtIndex:indexPath.row]
isEqualToString:@"0"]) // nothing
{
[market clearsContextBeforeDrawing];
[market setSelected:NO];
[market setImage:[UIImage imageNamed:@"Marketplace.png"]
forState:UIControlStateNormal];
market.enabled = YES;
}
}
[market addTarget:self action:@selector(marketPressedAction:)
forControlEvents:UIControlEventTouchDown];
[market setTag:indexPath.row];
[market setFrame:CGRectMake(200, 6, 30, 30)];
[cell.contentView addSubview:market];
return cell;
}
No comments:
Post a Comment