开发者

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

开发者 https://www.devze.com 2023-01-11 21:23 出处:网络
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 subvie

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 = [开发者_JS百科[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!


Ask the parent view to insert the subview, and code the parent so it knows how to manage swapping views around?

0

精彩评论

暂无评论...
验证码 换一张
取 消