【问题标题】:how to convert UIStoryBoard code to xib file code如何将 UIStoryBoard 代码转换为 xib 文件代码
【发布时间】:2013-05-23 13:16:50
【问题描述】:

我创建了一个具有侧边菜单(如 facebook)的应用程序,并且此菜单从左侧打开。

我想用 xib 文件创建这个应用程序,我从一个项目中得到帮助。在那个项目中存在 UIStoryBoard,我对这段代码有疑问:

    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
    self.leftVC = (LeftVC*)[storyboard instantiateViewControllerWithIdentifier:@"LeftVC"];;

    [self.navigationController.view.superview insertSubview:self.leftVC.view belowSubview:self.navigationController.view];

我想使用 xib 文件而不是故事板。 (我的xib文件是:LeftVC.xib)

【问题讨论】:

  • 你有一个带有 LeftVC 标识符的视图控制器还是只是 xib 的名字?

标签: ios objective-c storyboard xib


【解决方案1】:

我希望你有 LeftVC 对应的 VC。那就点个赞吧

LeftVC *leftVC = [LeftVC alloc][initWithNibName:@"LeftVC" bundle:nil];  
[self.navigationController.view.superview insertSubview:self.leftVC.view belowSubview:self.navigationController.view];

【讨论】:

  • 当运行应用程序崩溃并显示此页面:// BSD 许可证。作者:jano@jano.com.es #import "AppDelegate.h" int main(int argc, char *argv[]) { @autoreleasepool { return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); } }
  • 我使用这个代码:LeftVC *leftVC = [[LeftVC alloc]initWithNibName:@"LeftVC" bundle:nil]; [self.navigationController.view.superview insertSubview:leftVC.view belowSubview:self.navigationController.view];
  • 你在使用任何外部库你有一个navigationController吗?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2012-02-25
  • 1970-01-01
  • 1970-01-01
  • 2022-12-02
  • 2022-12-30
  • 2021-09-13
  • 2020-11-04
相关资源
最近更新 更多