0

我想用 textInput 框和按钮弹出一个视图。我不明白为什么 UITableView 工作,但 UIView 没有。

- (void)viewDidLoad
{
    [super viewDidLoad];
    self.containerView = [[UITableView alloc] initWithFrame:CGRectMake(20, 100,200,200)];
    [[self view]addSubview:self.containerView];
}

使用上面的代码我可以看到视图。但如果我改为:

- (void)viewDidLoad
{
    [super viewDidLoad];
    self.containerView = [[UIView alloc] initWithFrame:CGRectMake(20, 100,200,200)];
    [[self view]addSubview:self.containerView];
}

我什么也得不到,黑屏。什么都没有显示。有人可以告诉我原因吗?非常感谢。

4

1 回答 1

1
self.containerView = [[UIView alloc] initWithFrame:CGRectMake(20, 100,200,200)];
self.containerView.backgroundColor = [UIColor redColor];

试试这个代码。

于 2013-10-25T08:21:06.113 回答