使用 Xcode 5 创建基于 xib 的界面

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19632797/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 04:12:26  来源:igfitidea点击:

Create xib based interface with Xcode 5

iphonexcodeipadxib

提问by Mc.Lover

I am trying to create a new app with Singe View template but there is no xib or storyboard option to make my interface as xib file !!! why does Apple remove xib from iOS 7 ?!! How can I create application with xib interface files ?

我正在尝试使用 Singe View 模板创建一个新应用程序,但没有 xib 或故事板选项可以将我的界面设为 xib 文件!!!为什么 Apple 从 iOS 7 中删除了 xib ?!!如何使用 xib 接口文件创建应用程序?

enter image description here

在此处输入图片说明

回答by Rugmangathan

  • Create a new project
  • Select Single View Application
  • Set ProjectName and other settings
  • Save Project at location
  • Select Project in Navigator Panel in Left
  • Remove Main.storyboard file from project
  • Add New .xib file in Project
  • Set Main Interface to your .xib file in "General Tab" on right panel.
  • Paste following code in didFinishLaunchingWithOptionsmethod
  • 创建一个新项目
  • 选择单一视图应用程序
  • 设置 ProjectName 和其他设置
  • 将项目保存在位置
  • 在左侧导航器面板中选择项目
  • 从项目中删除 Main.storyboard 文件
  • 在项目中添加新的 .xib 文件
  • 在右侧面板的“常规选项卡”中将主界面设置为您的 .xib 文件。
  • didFinishLaunchingWithOptions方法中粘贴以下代码
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.rootViewController = [[UIViewController alloc] initWithNibName:@"YourViewController" bundle:nil];
[self.window makeKeyAndVisible];
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.rootViewController = [[UIViewController alloc] initWithNibName:@"YourViewController" bundle:nil];
[self.window makeKeyAndVisible];

回答by Antonio MG

Apple removed it because they just want to "force" everybody to use Storyboards, although from what I know, a big amount of people just don't find them useful.

Apple 删除了它,因为他们只是想“强迫”每个人使用 Storyboard,尽管据我所知,很多人只是觉得它们没有用。

I'm afraid you'll have to do it yourself, just create an empty app and set yourself the view.

恐怕你必须自己做,只需创建一个空的应用程序并为自己设置视图。

Check an example:

检查一个例子:

http://www.appcoda.com/hello-world-app-using-xcode-5-xib/

http://www.appcoda.com/hello-world-app-using-xcode-5-xib/

回答by Mahendra Y

Apple remove it from xcode 5 . you have only one option to choose storyboard. if you want to xibs then remove storyboard after creating singleView application and add xib manually. another option is to create application in xcode 4.6 or earliar version then run it on xcode 5.

Apple 从 xcode 5 中删除它。您只有一种选择来选择故事板。如果你想要 xibs 然后在创建 singleView 应用程序后删除故事板并手动添加 xib。另一种选择是在 xcode 4.6 或早期版本中创建应用程序,然后在 xcode 5 上运行它。