没有 Storyboard 和 ARC 的 Xcode [英] Xcode without Storyboard and ARC

查看:23
本文介绍了没有 Storyboard 和 ARC 的 Xcode的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经下载了新的 xcode-5 并且刚刚开始使用它.

i have downloaded new xcode-5 and just started using it.

我们可以直接创建包含 storyboard 和 ARC 的应用程序,它不像早期版本那样要求选项.

We can create application directly including storyboard and ARC , it is not asking for option like earlier versions.

所以,我的问题是如何在没有 ARC 和故事板的情况下使用 xcode5.我们必须手动删除故事板文件?或者有没有其他选择.

So, my question is how can we use xcode5 without ARC and storyboard. we have to manually remove storyboard file ? or is there any other option.

推荐答案

创建一个带有 Empty 应用程序的项目并添加任何视图控制器(我在这里添加了 TestViewController)

   - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions: (NSDictionary *)launchOptions
 {
   self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
   // Override point for customization after application launch.
   TestViewController *test = [[TestViewController alloc]     initWithNibName:@"TestViewController" bundle:nil];
   UINavigationController *nav = [[UINavigationController alloc]  initWithRootViewController:test];
   self.window.rootViewController = nav;
   [self.window makeKeyAndVisible];
   return YES;
 }

去除电弧的步骤

1) 在构建设置中将 Automatic Reference Counting 设置为 NO.

1) In build setting set Automatic Reference Counting to NO.

/////////////////////////////////////////////////////////////////////////结尾/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

如果您已经使用 storyboardARC 创建了应用程序,那么

If you have Already Created Application with storyboard and ARC then

移除故事板的步骤

1) 从您的项目中删除 Main.storyboard 文件.

1) Remove Main.storyboard file from your project.

2) 为您的控制器添加带有 xib 的新文件,如果在构建阶段未将其添加到已编译的源中,则手动添加.

2) Add new files with xib for your controller , if it is not added in compiled sources in build phases then add there manually.

3)plist 中删除主故事板文件基本名称.

4) 更改 appdelegate didFinishLaunchingWithOptions 文件并添加:

4) Change appdelegate didFinishLaunchingWithOptions file and add :

self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] ;

[self.window makeKeyAndVisible];

就像:

  - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
 {
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] ;

     // Override point for customization after application launch.

     TestViewController *test = [[TestViewController alloc]     initWithNibName:@"TestViewController" bundle:nil];
     UINavigationController *nav = [[UINavigationController alloc]  initWithRootViewController:test];
     self.window.rootViewController = nav;
     [self.window makeKeyAndVisible];

     return YES;
}

<小时><小时>

现在,在上面的例子中,你必须手动管理内存管理,如,



Now,in above example you have to manage memory management manually like ,

 self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease]; 

 [test release]; 

去除电弧的步骤

1) 在构建设置中将 Automatic Reference Counting 设置为 NO.

1) In build setting set Automatic Reference Counting to NO.

这篇关于没有 Storyboard 和 ARC 的 Xcode的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆