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

标签 ios objective-c cordova uiviewcontroller

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

在加载index.html之前是否要添加UIViewController文件?

例如:启动屏幕 --> VIEWCONTROLLER 简介 --> INDEX.html

enter image description here

最佳答案

转到类 >> 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/

相关文章:

javascript - ChartJS x 轴仅显示一年中的月份

iphone - 如何找到归档的目标文件?

ios - 在后台加载 UIWebView

objective-c - 一个项目的 xcode 4.6(xcode 崩溃)后无法重构(其他项目运行良好)

ios - 解析 Swift 文档?

javascript - Phonegap - 如何在 list 应用程序中存储文本,即使在应用程序关闭后也是如此

ios - 哪个更适合 OAuth 流程? SFSafariViewController? WKWeb View ?

ios - Azure 管道 : How to make the Agent use a MacOS variant that has iOS version 16. 1+?

iphone - 我如何在 cocoa/objective-c 中获取触摸的位置?

Android 后退按钮在 textarea 中退出 Phonegap-app