2012-11-16 41 views
1

我有一个左侧的tableview(它是一个iPad应用程序)和一个右侧的空子视图,用户触摸单元格时会填充该子视图。这是我的didSelect ...看起来像:子视图在添加时显示为灰色背景色

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 
    SecondViewController *remedyScreen = [[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil];  
    [self.rightPanel addSubview:remedyScreen.view]; 
    [tableView deselectRowAtIndexPath:indexPath animated:YES]; 
} 

我的问题是,这SecondViewController始终显示了一个灰色的背景和它的设置clearClear在厦门国际银行,也不透明属性为未选中状态。我假设这个奇怪的灰色背景颜色来自刚刚创建的子视图,因为即使将颜色添加到self.rightPanel,它也会在我将子视图添加到它时覆盖灰色。我已经完成了代码设置clearColor和Opaque = NO的设置,但是我得到了相同的灰色背景。我错过了那里的东西?

回答

6

试试这个:

UIView *backView = [[[UIView alloc] CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)]; 
backView.backgroundColor = [UIColor clearColor]; 
self.view.backgroundView = backView; 
+0

大,帮我解决这个问题。对不起,我不能投票,因为我的名声仍然很低! –

+0

没有问题。它对你解决问题很有帮助。 –

+0

出于好奇,不应该只是在xib中显示颜色设置吗? –