添加子视图,这是再次通过超级视图
问题描述:
我有uiviewController作为主视图,然后我添加了子视图叫做“supporteview”。现在我在supportview上以编程方式添加按钮。 由于某些原因,按钮不可见,但是当我在主视图中加载按钮时,我能够看到按钮。添加子视图,这是再次通过超级视图
[self.view addSubview:self.supportview]; [self.view bringSubviewToFront:self.supportView]; [self.supportView addSubview:self.btn]; [self.supportView bringSubviewToFront:self.button];
我已经加入滑块supportView然后加载按钮。
答
尝试将第1个按钮添加到supportView,然后将supportView添加到您的视图。您还可以使用视图检查,看看那里的按钮https://www.raywenderlich.com/98356/view-debugging-in-xcode-6
这将帮助你在运行时检查框架和约束
你是动态生成按钮,或者是里面的故事板? –
动态生成。 – Rupinder
尝试更新按钮的框架。将x和y原点设置为0.您的按钮框架。 –