2016-06-11 94 views
0

我有uiviewController作为主视图,然后我添加了子视图叫做“supporteview”。现在我在supportview上以编程方式添加按钮。 由于某些原因,按钮不可见,但是当我在主视图中加载按钮时,我能够看到按钮。添加子视图,这是再次通过超级视图

[self.view addSubview:self.supportview]; [self.view bringSubviewToFront:self.supportView]; [self.supportView addSubview:self.btn]; [self.supportView bringSubviewToFront:self.button];

我已经加入滑块supportView然后加载按钮。

+0

你是动态生成按钮,或者是里面的故事板? –

+0

动态生成。 – Rupinder

+0

尝试更新按钮的框架。将x和y原点设置为0.您的按钮框架。 –

回答

0

尝试将第1个按钮添加到supportView,然后将supportView添加到您的视图。您还可以使用视图检查,看看那里的按钮https://www.raywenderlich.com/98356/view-debugging-in-xcode-6

这将帮助你在运行时检查框架和约束

+0

SupportView被添加到故事板和我正在生成的事件按钮超过supportview。 – Rupinder

+0

然后你不需要下面的行[self.view addSubview:self.supportview]; [self.view bringSubviewToFront:self.supportView];只需在supportView –

+0

上添加按钮,但不会显示 – Rupinder

相关问题