如何在phonegap项目中的启动画面后添加UIViewController?

时间:2014-02-06 06:06:09

标签: ios objective-c cordova uiviewcontroller

我创建了一个phonegap ios项目。目前在启动画面之后它加载了一个index.html文件。我喜欢在启动画面后添加一个介绍viewcontroller,如下面的图像,用户可以选择关闭简介viewcontroller,以便他们可以看到index.html文件。

无论如何在加载index.html ??

之前添加UIViewController文件

例如:SPLASH SCREEN - >简介VIEWCONTROLLER - >的index.html

enter image description here

1 个答案:

答案 0 :(得分:1)

转到课程>> 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];    
}