2016-06-11 95 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

相關問題