所以我有一个 View ,在我的 viewcontoller 类中,我尝试使用以下代码添加一个 subview 。
UIButton *test = [[UIButton alloc]initWithFrame:CGRectMake(30, 100, 100, 100)];
[self.view addSubView:test];
什么也没发生,没有错误或任何事情。我知道它被调用,因为它位于 viewdidload 方法中。我有一个单独的类,我是 uiview 的子类,这与它有什么关系吗?
最佳答案
UIButton *test = [UIButton buttonWithType:UIButtonTypeRoundedRect];
test.frame = CGRectMake(30, 100, 100, 100);
[self.view addSubView:test];
关于ios - UIView 不允许我添加 subview ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13983982/