【问题标题】:How to develop an app with multiple screens using xib?如何使用 xib 开发具有多个屏幕的应用程序?
【发布时间】:2016-02-22 13:16:34
【问题描述】:

我知道这是一个非常愚蠢的问题。但是我是ios开发新手。我什至不知道基本知识。

在Xcode 7.1中,当我创建一个新项目时,storyBoard是默认的。我想使用xib文件开发一个具有多个屏幕的应用程序。请告诉怎么做?

  1. 如何设置启动画面?
  2. 如何连接不同的xib文件?

不管怎样,你能告诉我如何一步一步地使用xib构建一个简单的项目吗。非常感谢。

【问题讨论】:

  • 你的英语可能是阻止你自己找到这些东西的原因。我搜索了“xib 教程”并得到了this,我搜索了“xib 启动屏幕”并得到了this。谷歌“视图控制器转换”解决您关于连接不同 xib 文件的问题。

标签: ios objective-c storyboard xib


【解决方案1】:

如果您想拥有多个 XIB,请按照以下步骤操作

     First remove the storyboard file from your project
     In Deployment Info of TARGETS,delete Main from Main Interface
     The create the View(XIB). Give the name as ViewController.Xib

然后在appDelegate.h中

    import - #import "ViewController.h"
    @property (strong, nonatomic) ViewController *vc;

然后在appDelegate.m中

    @synthesize vc;

然后在 didFininshLaunchingWithOptions 中

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 
   {
      // Override point for customization after application launch.

      self.window = [[UIWindow alloc]initWithFrame:[[UIScreen mainScreen]bounds]];
      vc = [[ViewController alloc]initWithNibName:@"ViewController" bundle:nil];
      UINavigationController *navigationVC  = [[UINavigationController alloc]initWithRootViewController:vc];
      self.window.rootViewController = navigationVC;
      self.window.backgroundColor = [UIColor clearColor];
      [self.window makeKeyAndVisible];
      return YES;
   }

接下来如果要创建多个xib,你可以根据自己的需求用.h,.m和xib创建。

【讨论】:

  • 你帮了我很多。非常感谢。
  • 如果对你有帮助,请在我的回答上打勾。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2010-09-28
  • 1970-01-01
  • 1970-01-01
  • 2012-01-14
  • 2015-04-06
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多