简体   繁体   中英

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

I have some buttons on a view for navigation and when a user presses them my code inserts the appropriate new view page (xib) under the navigation buttons. Each new view page that I insert as a subview has some buttons that are supposed to pop up a new view over everything, including the navigation buttons. Here's one of my button actions

    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

The issue here is that my new subview is inserted as a child of the navigation buttons view, so then when I use an action to addsubview from that viewcontroller, the view is added on top of that view controller, but not on top of the buttons because those are in the parent view. How can I solve this?

Thanks!

要求父视图插入子视图,并对父视图进行编码,使其知道如何管理周围的交换视图?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM