简体   繁体   English

Xcode没有Storyboard和ARC

[英]Xcode without Storyboard and ARC

i have downloaded new xcode-5 and just started using it. 我已经下载了新的xcode-5并且刚刚开始使用它。

We can create application directly including storyboard and ARC , it is not asking for option like earlier versions. 我们可以直接创建应用程序,包括storyboard和ARC,它不要求像早期版本那样的选项。

So, my question is how can we use xcode5 without ARC and storyboard. 所以,我的问题是如何在没有ARC和故事板的情况下使用xcode5。 we have to manually remove storyboard file ? 我们必须手动删除storyboard文件? or is there any other option. 还是有其他选择。

Create a project with an Empty application and Add any viewcontroller (i added TestViewController here) 使用Empty应用程序创建一个项目并添加任何viewcontroller(我在这里添加了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;
 }

STEPS FOR REMOVE ARC 消除电弧的步骤

1) In build setting set Automatic Reference Counting to NO . 1)在构建设置中将自动参考计数设置为NO

///////////////////////////////////////////////////////////////////////////END/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////// /////////////////////////结束//////////////////////// ////////////////////////////////////////////////// ////////////////////////////////////////////////// ////////////////////////////////////////////////// ////////////////////////////////////////////////// ///////////////////////

If you have Already Created Application with storyboard and ARC then 如果您已经使用故事板ARC创建了应用程序

STEPS FOR REMOVE STORY BOARD 删除故事板的步骤

1) Remove Main.storyboard file from your project. 1)从项目中删除Main.storyboard文件。

2) Add new files with xib for your controller , if it is not added in compiled sources in build phases then add there manually. 2)为控制器添加带有xib的新文件,如果在构建阶段未在编译源中添加,则手动添加。

3) Remove Main storyboard file base name from plist . 3)plist中删除主故事板文件基本名称

4) Change appdelegate didFinishLaunchingWithOptions file and add : 4)更改appdelegate didFinishLaunchingWithOptions文件并添加:

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

[self.window makeKeyAndVisible];

just like : 就像 :

  - (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]; 

STEPS FOR REMOVE ARC 消除电弧的步骤

1) In build setting set Automatic Reference Counting to NO . 1)在构建设置中将自动参考计数设置为NO

Instead of delete the storyboard file, you can Create a new project with Empty Application template. 您可以使用空应用程序模板创建新项目,而不是删除情节提要文件。 So that you can avoid the storyboard file creation. 这样就可以避免故事板文件的创建。

Use following steps to omit storyboard: 使用以下步骤省略故事板: 在此输入图像描述

  1. Create a new project with Empty Application template. 使用Empty Application模板创建一个新项目。
  2. Add a new viewController (Example: LoginViewController ) 添加一个新的viewController(例如: LoginViewController
  3. Change the didFinishLaunchingWithOptions in AppDelegate.m file as specified below. 更改AppDelegate.m文件中的didFinishLaunchingWithOptions ,如下所示。

Change To: 改成:

#import "LoginViewController.h"

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

    // Override point for customization after application launch.
    self.window.backgroundColor = [UIColor whiteColor];

    LoginViewController *loginVC = [[LoginViewController alloc] initWithNibName:@"LoginViewController" bundle:nil];
    UINavigationController *navigationController = [[UINavigationController alloc]  initWithRootViewController:loginVC];

    self.window.rootViewController = navigationController;
    [self.window makeKeyAndVisible];

    return YES;
}

Remove ARC: Go to Build Setting -> Objective-C Automatic Reference Counting -> NO 删除ARC:转到构建设置 - > Objective-C自动引用计数 - >否

create new project 创建新项目

![Create new Project] ![创建新项目]

删除信息中的主故事板文件基本名称

//remove Main storyboard file base name in Info //删除Info中的主要故事板文件基本名称

Add This Code In appdelegate 在appdelegate中添加此代码

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

    // Override point for customization after application launch.
    self.window.backgroundColor = [UIColor whiteColor];

    LoginViewController *loginVC = [[LoginViewController alloc] initWithNibName:@"LoginViewController" bundle:nil];
    UINavigationController *navigationController = [[UINavigationController alloc]  initWithRootViewController:loginVC];

    self.window.rootViewController = navigationController;
    [self.window makeKeyAndVisible];

    return YES;
}

Then automatic remove your storyboard. 然后自动删除您的故事板。

Please Try this... successfully Executed. 请尝试这个...成功执行。 thanks 谢谢

ShortCut: I Prefer ShortCut:我更喜欢

Create the project without Storyboard and ARC in xcode4 and then open that project in xcode5 . 在xcode4中创建没有Storyboard和ARC的项目,然后在xcode5中打开该项目。

Xcode 4 had the "Use Storyboards" checkbox when you created a new project. 创建新项目时,Xcode 4具有“使用故事板”复选框。 It is possible to grab the old Xcode 4 application templates (XML files) and convert them to Xcode 5. That way, you get the old templates back that let you choose whether you want storyboards or not. 可以获取旧的Xcode 4应用程序模板(XML文件)并将它们转换为Xcode 5.这样,您可以返回旧模板,让您选择是否需要故事板。


I wrote a script that does all that work for you: https://github.com/jfahrenkrug/Xcode4templates 我编写了一个脚本,它可以为您完成所有工作: https //github.com/jfahrenkrug/Xcode4templates


After running the script, you will have an "Xcode 4" section in the "New Project" screen: 运行脚本后,“新建项目”屏幕中将显示“Xcode 4”部分:

在此输入图像描述

And then - Alas! 然后 - 唉! - you get your beloved choices back: - 你得到了你心爱的选择:

在此输入图像描述

You will need a copy of the Xcode 4 .app bundle from http://developer.apple.com/ios to use this script. 您需要http://developer.apple.com/ios上的Xcode 4 .app软件包的副本才能使用此脚本。

I have a Tip: 我有一个提示:

  1. The First: I create my project by XCode 4.6 (Because this version is nearest to XCode 5). 第一个:我通过XCode 4.6创建我的项目(因为这个版本离XCode 5最近)。
    • Of course that with XCode 4.6, you can chose use or not using ARC, Storyboard. 当然,使用XCode 4.6,您可以选择使用或不使用ARC,Storyboard。
  2. The Second: After that I will open my Project with XCode 5. => I think that Xcode 5 will understand that project is use nonARC, and of course, do not have Storyboard. 第二个:之后我将使用XCode 5打开我的项目。=>我认为Xcode 5将理解该项目是使用nonARC,当然,没有Storyboard。

I hope your project will work! 我希望你的项目能够奏效! :D :d

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM