我最近从故事板转换为XIB。因为我有大量的视图,并且通过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];
答案 0 :(得分:2)
首先,您应该将infoView
从故事板转换为infoView.xib
,然后:
infoView *infoViewController = [[infoView alloc]initWithNibName:@"infoView" bundle:nil];
infoViewController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentViewController:infoViewController animated:YES completion:nil];