【问题标题】:Add UIViewController below UITabBarController on iOS like youtube app在 iOS 上的 UITabBarController 下方添加 UIViewController,如 youtube 应用程序
【发布时间】:2012-09-11 18:15:01
【问题描述】:

我有一个带有几个标签的UITabBarController。 当我在第一个视图(选项卡)上单击UIButton 时,我想将整个UITabBarController 滑出并显示位于UITabBarController 下方的新UIView

当您开始播放视频时,youtube iPhone 应用上会发生类似的情况。

我像这样将 UITabBarController 添加到 appDelegate 中的窗口:

self.window.rootViewController = self.tabBarController;

解决方案:

[self.view.window insertSubview:welcomeViewController.view atIndex:0];
[UIView animateWithDuration:1.0 delay:0. options:UIViewAnimationOptionBeginFromCurrentState animations:^{
    CGRect frame = self.tabBarController.view.frame;
    frame.origin.x += 400;
    self.tabBarController.view.frame = frame;
} completion:^(BOOL finished) {
    //
}];

【问题讨论】:

    标签: iphone ios view uitabbarcontroller slide


    【解决方案1】:

    尝试将标签栏控制器框架移到视线之外:

    CGRect newFrame = tabBarController.view.frame;
    newFrame.origin.y += winHeight;
    [UIView
        animateWithDuration:0.5
        animations:^{
            tabBarController.view.frame = newFrame;
        }];
    

    【讨论】:

    • 好的,这行得通。但是,当我将新视图添加到 [self.view addSubview:] 时,这个新视图位于堆栈的哪个位置?是低于 tabbarController 还是高于?
    • 当我滑出视图时,如何确保视图已经在 tabBarController 下方?
    • 我明白了:[self.view.window insertSubview:newViewController.view atIndex:0];
    【解决方案2】:

    在第一个视图(选项卡)上单击UIButton 时为UITabBarController 添加一些动画?当调用下一个视图时,只需在按钮的动作中添加动画即可。为此,您还必须设置一个计时器以让UITabBarController 明显缓解

    【讨论】:

    • 这是如何将整个 UITabBarController(包括标签)滑出窗口的问题...?
    猜你喜欢
    • 2013-08-11
    • 2014-03-15
    • 1970-01-01
    • 2011-09-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多