- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
// NSString *CellIdentifier = [NSString stringWithFormat:@"cell%d",indexPath.row];
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
//clear all the cells subview before drawing the cell
for(UIView *view in cell.contentView.subviews)
{
if ([view isKindOfClass:[UIView class]])
{
[view removeFromSuperview];
}
}
if (arrPlaceId.count>0)
{
lblPlacename=[[UILabel alloc]initWithFrame:CGRectMake(30, 3, 300, 20)];
lblPlacename.font=[UIFont fontWithName:@"arial" size:15];
lblPlacename.textColor=[UIColor whiteColor];
lblPlacename.backgroundColor=[UIColor clearColor];
lblAddress=[[UILabel alloc]initWithFrame:CGRectMake(30, 20, 300, 18)];
lblAddress.font=[UIFont fontWithName:@"arial" size:15];
lblAddress.textColor=[UIColor whiteColor];
lblAddress.backgroundColor=[UIColor clearColor];
lblPlacename.text=[arrPlaceName objectAtIndex:indexPath.row];
lblAddress.text=[arrPlaceAddress objectAtIndex:indexPath.row];
[cell addSubview:lblPlacename];
[cell addSubview:lblAddress];
}
return cell;
}
質問する
198 次