我最近从 Storyboard 转换为 XIB。因为我有大量的 View ,而且通过 git 存储库更容易使用 XIB。 (该应用程序现在也可用于 iOS 4)。
现在这里是我曾经拥有的代码,但我想知道如果没有 Storyboard 但使用 XIB,我将如何实现相同的代码:
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:[NSBundle bundleForClass:[self class]]];
infoView *infoViewController = [storyboard instantiateViewControllerWithIdentifier:[defaults objectForKey:@"launchScreen"]];
infoViewController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentViewController:infoViewController animated:YES completion:nil];
最佳答案
首先,您应该将 infoView
从 Storyboard 转换为 infoView.xib
,然后:
infoView *infoViewController = [[infoView alloc]initWithNibName:@"infoView" bundle:nil];
infoViewController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentViewController:infoViewController animated:YES completion:nil];
关于objective-c - Storyboard -> XIB |加载 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11979633/