一、删除main.storyboard,并在info.plist中删除main storyboard file base name
二、在-(BOOL)application:didFinishLauchingWithOptions:中添加以下代码
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
//创建UIWindow对象
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
//设置UIWindow的背景色
self.window.backgroundColor = [UIColor whiteColor];
//将该UIWindow对象设为主窗口并显示出来
[self.window makeKeyAndVisible];
//创建一个UIViewController对象
UIViewController *controller = [[UIViewController alloc] init];
self.window.rootViewController = controller;
//创建一个UIView对象
UIView *rootView = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
//设置controller显示rootView
controller.view = rootView;
//创建一个按钮
UIButton *button = [UIButton b

这篇博客介绍了如何在iOS应用中不使用main.storyboard,而是通过代码创建UI界面。作者首先删除了main.storyboard文件,并在info.plist中移除了主故事板引用。接着在应用程序启动方法中添加代码来设置界面元素并添加子视图。作者提到,由于有cocos2d-x的背景,这部分工作相对较熟悉。
最低0.47元/天 解锁文章
906

被折叠的 条评论
为什么被折叠?



