Iphone 添加带有UIAbbarController的持久UIView

Iphone 添加带有UIAbbarController的持久UIView,iphone,objective-c,uiview,uitabbarcontroller,depth,Iphone,Objective C,Uiview,Uitabbarcontroller,Depth,我有一个应用程序使用UITabBarController,我还有另一个视图需要从选项卡栏控件后面向上滑动,但在选项卡栏内容前面。如果这还不清楚,想象一下一则广告在一个选项卡式应用程序中向上滑动,出现在除选项卡栏按钮之外的所有东西前面 到目前为止,我有这样的代码,但我愿意改变它,如果有更好的方法来做到这一点 tabBarController.viewControllers = [NSArray arrayWithObjects:locationNavController, emergencyNav

我有一个应用程序使用UITabBarController,我还有另一个视图需要从选项卡栏控件后面向上滑动,但在选项卡栏内容前面。如果这还不清楚,想象一下一则广告在一个选项卡式应用程序中向上滑动,出现在除选项卡栏按钮之外的所有东西前面

到目前为止,我有这样的代码,但我愿意改变它,如果有更好的方法来做到这一点

tabBarController.viewControllers = [NSArray arrayWithObjects:locationNavController, emergencyNavController, finderNavController, newsNavController, nil]; 

aboutView = [[AboutView alloc] initWithFrame:CGRectMake(0, window.frame.size.height - tabBarController.tabBar.frame.size.height - 37 ,
                                                        320, window.frame.size.height - tabBarController.tabBar.frame.size.height)];


[window addSubview:tabBarController.view];    // adds the tab bar's view property to the window
[window addSubview:aboutView]; // this is the view that slides in
[window makeKeyAndVisible];

目前aboutView是UIView的一个子类,位于其底部的起始位置,但它隐藏了tabBarController。如何更改此设置以使选项卡位于顶部,但仍将aboutView置于其他内容的前面?

您需要将aboutView添加为当前活动视图控制器中视图的子视图。您可以通过属性访问该视图

您可以将代码添加到aboutView实现中,以便在视图出现时设置其动画

我在一个弹出视图中做了类似的事情,我想显示在选项卡栏控件下。您可以在aboutView实现的消息中添加一些代码:

- (void)didMoveToSuperview
{
    CGRect currentFrame = self.frame;

    // animate the frame ... this just moves the view up a 10 pixels. You will want to
    // slide the view all the way to the top
    CGRect targetFrame = CGRectOffset(currentFrame, 0, -10);

    // start the animation block and set the offset
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:0.5]; // animation duration in seconds
    [UIView setAnimationDelegate:self];

    self.frame = targetFrame;

    [UIView commitAnimations];  
}
因此,当您的aboutView添加到选定视图控制器的视图时,它会自动设置动画。

@user663222没问题:)很高兴这很有用。