我创建了一个phonegap ios项目。目前,在启动屏幕之后,它加载一个index.html文件。我喜欢在启动屏幕后添加一个介绍 View Controller ,如下图所示,并且用户可以选择关闭介绍 View Controller ,以便他们可以看到 index.html 文件。
在加载index.html之前是否要添加UIViewController文件?
例如:启动屏幕 --> VIEWCONTROLLER 简介 --> INDEX.html
最佳答案
转到类 >> 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];
}
关于ios - 如何在 phonegap 项目的启动画面后添加 UIViewController?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21595271/