将xib作为子视图插入,然后在父视图上添加该xib的子视图

时间:2010-08-12 20:02:48

标签: iphone objective-c xcode

我在导航视图上有一些按钮,当用户按下它们时,我的代码会在导航按钮下插入相应的新视图页面(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

这里的问题是我的新子视图是作为导航按钮视图的子项插入的,所以当我使用动作从该视图控制器添加子视图时,视图将添加到该视图控制器的顶部,但不会在顶部按钮,因为它们在父视图中。我该如何解决这个问题?

谢谢!

1 个答案:

答案 0 :(得分:0)

请求父视图插入子视图,并对父视图进行编码,以便它知道如何管理交换视图?

相关问题