在appDelegate中第一次呈现视图 [英] Presenting a view for the first time in appDelegate

查看:99
本文介绍了在appDelegate中第一次呈现视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目标:



当我的应用启动时 - 我需要它在显示视图才能进入主页屏幕。它是一个标签栏应用程序,此视图不是标签栏的一部分。



我使用的是Storyboards和Xcode 5 - 仅限iOS7应用。



问题:



我的代码会检查应用是否是首次启动与否。基于此,我想向用户呈现一次性视图。



我尝试了什么:



以下代码位于appDelegate中这个应用就是这一切的开始。我在那里调用以下代码:

   - (void)showCountrySettings 
{

if(self.termsHaveBeenAccepted){

BBCounterySettingsViewController * countrySettings = [[BBCounterySettingsViewController alloc] initWithNibName:@Viewbundle:nil];

UIStoryboard * storyboard = [UIStoryboard storyboardWithName:@MainStoryboardbundle:nil];
UIViewController * vc = [storyboard instantiateViewControllerWithIdentifier:@IDENTIFIER];
[self.navigationController pushViewController:vc animated:YES];
}

我的编译错误为 [self.navigationController。 。] 不存在。也不是 [self.tabbarcontroller ...];



这很明显,因为我没有设置属性对于这些 - 但我如何解决这个问题并将标签栏连接到故事板?



我错过了什么?

解决方案

   - (BOOL)应用程序:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary * )launchOptions 
{
//在应用程序启动后覆盖自定义点。


if(!isAgreementAccepted)
{

UIStoryboard * storyboard = [UIStoryboard storyboardWithName:@Mainbundle:nil];
UIViewController * vc = [storyboard instantiateViewControllerWithIdentifier:@IDD];
self.window.rootViewController = vc;
}

返回YES;
}

如果不接受协议,请设置T& C viewController as rootViewController 当用户单击接受按钮,然后以root身份设置 TabBarviewController 。 / p>

你可以通过申请委托访问任何地方的寡妇对象

  [ [[UIApplication sharedApplication]委托]窗口] .rootViewController = tabViewController。 


The goal:

When my app starts up - I need it to display a view before it gets to the "Home" screen. Its a tab bar application and this view is not part of the tabbar.

I am using Storyboards and Xcode 5 - iOS7 only app.

The problem:

I have code that will check if the app is first launch or not. Based on that, I then want to present a one time only view to the user.

What I have tried:

The following code is in the appDelegate of the application as this is where it all starts. I call the following bit of code in there:

-(void)showCountrySettings
{

    if (self.termsHaveBeenAccepted){

        BBCounterySettingsViewController *countrySettings = [[BBCounterySettingsViewController alloc]initWithNibName:@"View" bundle:nil];

        UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
        UIViewController *vc = [storyboard instantiateViewControllerWithIdentifier:@"IDENTIFIER"];
        [self.navigationController pushViewController:vc animated:YES];
}

I get compile errors as [self.navigationController..] doesn't exist. Nor does [self.tabbarcontroller...];

This is obvious as I don't have properties setup for these - but how do I go about resolving this and connecting the tab bar to the storyboard?

What am I missing?

解决方案

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    // Override point for customization after application launch.


    if(!isAgreementAccepted)
    {

    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
    UIViewController *vc = [storyboard instantiateViewControllerWithIdentifier:@"IDD"];
    self.window.rootViewController=vc;
    }

    return YES;
}

If agreement is not accepted set the T&C viewController as rootViewController when user click the accept button then set the TabBarviewController as root.

u can access the widow object through application delegate any where

[[[UIApplication sharedApplication]delegate] window].rootViewController=tabViewController.

这篇关于在appDelegate中第一次呈现视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆