我有一个透明背景颜色的UITableView,它的每个单元都有自定义背景视图和灰色选择样式。选择工作正常,但是当我选择并向上或向下拖动桌面视图时,单元格将其背景更改为透明而非自定义。我该怎样修复它?所选的UITableViewCell更改Scroll背景
编辑:源代码的要求安德烈Morujão
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
RestaurantInfo *restaurantInfo = [requestBean.restaurantArray objectAtIndex:indexPath.row];
UITableViewCell *cell = [tableView
dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc]
initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:CellIdentifier] autorelease];
}
else {
cell = nil;
cell = [[[UITableViewCell alloc]
initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:CellIdentifier] autorelease];
}
[cell setSelectionStyle:UITableViewCellSelectionStyleGray];
UIImageView *bgView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 320, 100)];
[bgView setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"table_cell_bg.png"]]];
[cell setBackgroundView:bgView];
UILabel *restaurantNameLabel = [[UILabel alloc] initWithFrame:CGRectMake(5, 5, 310, 15)];
[restaurantNameLabel setFont:[UIFont boldSystemFontOfSize:16]];
[restaurantNameLabel setText:restaurantInfo.restaurantName];
[restaurantNameLabel setBackgroundColor:[UIColor clearColor]];
[restaurantNameLabel setUserInteractionEnabled:NO];
[cell addSubview:restaurantNameLabel];
return cell;
}
你可以粘贴你的tableView:cellForRowAtIndexPath:? – 2011-05-03 09:11:39
我已经像你说的那样用方法 – 2011-05-03 09:37:32