【问题标题】:Display Image To Extend Splash Screen Using Storyboards in iPhone SDK在 iPhone SDK 中使用 Storyboards 显示图像以扩展启动画面
【发布时间】:2013-10-03 17:49:09
【问题描述】:

我有这个带有标签的应用程序,每个标签的根视图控制器都是一个导航控制器。我想在应用程序忙于解析 JSON 并将其加载到我的核心数据堆栈中并使用淡出动画将其从超级视图中删除时显示我的启动画面或启动图像。我尝试了这段代码以使其工作,但我被卡住了,因为图像仅显示在导航控制器内的视图上。我想要的是全屏查看状态栏,就像您在启动应用程序时看到的那样。

_launchImageView = [[UIImageView alloc] initWithFrame:[UIScreen mainScreen].bounds];

if (kFourInchDevice) {
    _launchImageView.image = [UIImage imageNamed:@"Default-568h@2x.png"];
}

[self.view addSubview:_launchImageView];
[self.view bringSubviewToFront:_launchImageView];

这是我关闭它时的代码:

[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.0];
[UIView setAnimationCurve:UIViewAnimationCurveLinear];
[UIView setAnimationTransition:UIViewAnimationTransitionNone forView:self.view cache:YES];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(launchImageFadeAnimationDidFinished)];
_launchImageView.alpha = 0.0;
[UIView commitAnimations];

- (void)launchImageFadeAnimationDidFinished
{
    [_launchImageView removeFromSuperview];
}

关于如何做到这一点的任何想法?谢谢!

【问题讨论】:

    标签: xcode image uiimageview storyboard splash-screen


    【解决方案1】:

    我认为您在启动画面中隐藏 NavBar 时遇到了问题,不是吗? 只需在您的故事板中添加一个额外的 ViewController。 然后在属性选项卡下的实用程序(左侧栏)下 - 视图控制器使 VC 初始视图控制器。

    在您的视图中调用关注确实加载

    - (void) hideNavBar {
    UINavigationBar *navBar = self.navigationController.navigationBar;
        navBar.hidden = TRUE;
    }
    

    然后当你完成你的 json 解析器 -

    #pragma mark - Delegates
    #pragma mark JSON Request
    
    -(void) connectionReady; {
    
     NextVC *viewController = [self.storyboard
                                                     instantiateViewControllerWithIdentifier:@"NextVC"];
            [self.navigationController pushViewController:viewController
                                                 animated:YES];
    }
    

    最后在 NextVC 中

    - (void) showNavBar {
        UINavigationBar *navBar = self.navigationController.navigationBar;
        navBar.hidden = FALSE;
    }
    

    【讨论】:

    • 我有点希望是否有其他方法可以创建单独的UIViewController,但似乎这是唯一的方法。由于我使用的是选项卡,因此无法将此视图设为初始视图。
    • 是的,你可以关注这个stackoverflow.com/questions/9028534/…
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-11-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多