簡體   English   中英

插入一個xib作為子視圖,然后在父視圖上從該xib添加一個子視圖

[英]insert a xib as a subview, then add a subview from that xib over the parent view

我在視圖上有一些用於導航的按鈕,當用戶按下它們時,我的代碼將在導航按鈕下插入相應的新視圖頁面(xib)。 我作為子視圖插入的每個新視圖頁面都有一些按鈕,應該在所有內容上彈出一個新視圖,包括導航按鈕。 這是我的按鈕動作之一

    pg5 *pg5view = [[pg5 alloc] init]; //alloc and init UIViewController class for the view to be inserted.
    [self.view insertSubview:pg5view.view atIndex:1]; //insert the subview under the menu but above the last subview displayed
    [[[self.view subviews] objectAtIndex:0]removeFromSuperview]; //remove the last subview displayed

這里的問題是將新的子視圖作為導航按鈕視圖的子級插入,因此當我使用操作從該視圖控制器添加子視圖時,該視圖將添加到該視圖控制器的頂部,而不是按鈕的頂部因為它們在父視圖中。 我該如何解決?

謝謝!

要求父視圖插入子視圖,並對父視圖進行編碼,使其知道如何管理周圍的交換視圖?

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM