在子视图上添加按钮,子视图又在父视图上

Add button over subview which is again over a superview

我有 uiviewController 作为主视图,然后我添加了名为 "supporteview" 的子视图。现在我在 supportview 上以编程方式添加按钮。 由于某些原因,按钮不可见,但是当我在主视图上加载按钮时,我能够看到按钮。

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

我在 supportView 中添加了滑块,然后加载按钮。

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

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