ios 没有 Storyboard 和 ARC 的 Xcode
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17234172/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Xcode without Storyboard and ARC
提问by PJR
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. we have to manually remove storyboard file ? or is there any other option.
所以,我的问题是我们如何在没有 ARC 和故事板的情况下使用 xcode5。我们必须手动删除故事板文件?或者有没有其他选择。
回答by PJR
Create a project with an Empty application and Add any viewcontroller (i added TestViewController here)
创建一个带有空应用程序的项目并添加任何视图控制器(我在这里添加了 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 Countingto NO.
1)在构建设置中将Automatic Reference Counting设置为NO。
///////////////////////////////////////////////////////////////////////////END///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////// /////////////////////////结尾//////////////////////// ///////////////////////////////////////////////// ///////////////////////////////////////////////// ///////////////////////////////////////////////// ///////////////////////////////////////////////// ///////////////////////
If you have Already Created Application with storyboardand ARCthen
如果您已经使用故事板和ARC创建了应用程序,那么
STEPS FOR REMOVE STORY BOARD
移除故事板的步骤
1)Remove Main.storyboardfile 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 namefrom plist.
3)从plist 中删除主情节提要文件基本名称。
4)Change appdelegate didFinishLaunchingWithOptionsfile 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 Countingto NO.
1)在构建设置中将Automatic Reference Counting设置为NO。
回答by Raj Subbiah
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:
使用以下步骤省略故事板:
- Create a new project with Empty Application template.
- Add a new viewController (Example:
LoginViewController
) - Change the
didFinishLaunchingWithOptions
inAppDelegate.m
file as specified below.
- 使用 Empty Application 模板创建一个新项目。
- 添加一个新的viewController(例如:
LoginViewController
) - 按照下面的说明更改
didFinishLaunchingWithOptions
inAppDelegate.m
文件。
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:转到 Build Setting -> Objective-C Automatic Reference Counting -> NO
回答by Ketan Patel
create new project
创建新项目
![Create new Project]
![创建新项目]
//remove Main storyboard file base name in 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
请试试这个...成功执行。谢谢
回答by SwapnilPopat
ShortCut: I Prefer
捷径:我更喜欢
Create the project without Storyboard and ARC in xcode4 and then open that project in xcode5 .
在 xcode4 中创建没有 Storyboard 和 ARC 的项目,然后在 xcode5 中打开该项目。
回答by Johannes Fahrenkrug
Xcode 4 had the "Use Storyboards" checkbox when you created a new project. 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 具有“使用故事板”复选框。可以获取旧的 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/iosto use this script.
您将需要来自http://developer.apple.com/ios的 Xcode 4 .app 包的副本才能使用此脚本。
回答by Linh Nguyen
I have a Tip:
我有一个提示:
- The First: I create my project by XCode 4.6 (Because this version is nearest to XCode 5).
- Of course that with XCode 4.6, you can chose use or not using ARC, Storyboard.
- 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 4.6 创建我的项目(因为这个版本最接近 XCode 5)。
- 当然,在 XCode 4.6 中,您可以选择使用或不使用 ARC、Storyboard。
- 第二:之后我将使用 XCode 5 打开我的项目。 => 我认为 Xcode 5 会理解该项目是使用 nonARC,当然,没有 Storyboard。
I hope your project will work! :D
我希望你的项目能成功!:D