2011-03-02 97 views
0

我有一個圖形視圖,我想重疊一些按鈕。當我使用按鈕創建一個筆尖並在添加圖形後將其添加爲子視圖時,它只是在白色屏幕上顯示按鈕。如何在iOS上堆疊子視圖?

GraphViewController *graphViewController = [[GraphViewController alloc] init]; 
[self.view addSubview:graphViewController.view]; 
GraphButtonViewController *graphButtonViewController = [[GraphButtonViewController alloc] initWithNibName:@"GraphButtonView" bundle:nil]; 
[self.view addSubview:graphButtonViewController.view]; 
+0

那麼GraphButtonView會保存按鈕?那「GraphButton」將會在「GraphView」中?如果是這樣,您可以簡單地添加GraphButtonViewController.view作爲圖形視圖的子視圖 [graphViewController.view addSubview:graphButtonViewController.view]; – 2011-03-02 00:29:47

回答

1

您是否嘗試讓您的GraphButtonView xib具有透明背景(它是(主)視圖?

+0

是的,我剛剛意識到這是問題,謝謝。一個問題是按鈕視圖阻止了圖形上的功能。是通過使筆尖非常小(僅在按鈕周圍)來解決這個問題的方法嗎?或者我應該嘗試以編程方式添加UIButtons或其他東西。 – 2011-03-02 00:32:58

+0

我通常以編程方式添加重疊按鈕。這樣,如果我調整圖形大小,我可以將按鈕移動到合適的位置。 – hotpaw2 2011-03-02 00:34:25

+0

您可以爲按鈕製作任何尺寸的視圖容器。如果你喜歡在IB工作,那麼確保XIB的主視圖有狀態欄 - 無。您現在可以重新調整視圖的大小。 – 2011-03-02 01:25:38