【问题标题】:How can i add UIViewController after splash screen in phonegap project?如何在 phonegap 项目的闪屏后添加 UIViewController?
【发布时间】:2014-02-06 06:06:09
【问题描述】:

我已经创建了一个 phonegap ios 项目。目前在启动屏幕之后它加载了一个 index.html 文件。我喜欢在初始屏幕之后添加一个介绍视图控制器,如下图所示,用户可以选择关闭介绍视图控制器,以便他们可以看到 index.html 文件。

有没有在加载 index.html 之前添加 UIViewController 文件??

例如:启动画面 --> VIEWCONTROLLER 简介 --> INDEX.html

【问题讨论】:

    标签: ios objective-c cordova uiviewcontroller


    【解决方案1】:

    转到 Classes >> AppDelegate.m 文件用此代码替换 didFinishLaunchingWithOptions 函数

    - (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions
    {
    CGRect screenBounds = [[UIScreen mainScreen] bounds];
    
    self.window = [[[UIWindow alloc] initWithFrame:screenBounds] autorelease];
    self.window.autoresizesSubviews = YES;
    
    self.viewController = [[[MainViewController alloc] init] autorelease];
    self.viewController.useSplashScreen = YES;      
    UIViewController *myController = [[UIViewController alloc] init];    
    UIView *myView = [[UIView alloc] initWithFrame:self.viewController.view.frame];
    myView.backgroundColor = [UIColor whiteColor];
    myController.view = myView;    
    UINavigationController *myNav = [[UINavigationController alloc] initWithRootViewController:myController];
    
    UIBarButtonItem *leftButton = [[UIBarButtonItem alloc] initWithTitle:@"Cancel"
                                                                    style:UIBarButtonItemStyleDone target:self action:@selector(cancel)];   
    myController.navigationItem.leftBarButtonItem = leftButton;   
    self.window.rootViewController = myNav;
    [self.window makeKeyAndVisible];
    
     return YES;
    }
    
    -(void)cancel{
      self.window.rootViewController = self.viewController;
      [self.window makeKeyAndVisible];    
    }
    

    【讨论】:

    • 你能告诉我如果我添加这个会发生什么吗?
    • 根据 SPLASH SCREEN --> INTRODUCTION VIEWCONTROLLER --> INDEX.html 在启动画面加载此自定义视图控制器后左侧有取消按钮,您在加载 index.html 后使用此按钮执行操作文件
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-03-18
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多