故事板 - > XIB |加载视图

时间:2012-08-16 01:46:29

标签: objective-c ios xcode storyboard xib

我最近从故事板转换为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];

1 个答案:

答案 0 :(得分:2)

首先,您应该将infoView从故事板转换为infoView.xib,然后:

    infoView *infoViewController = [[infoView alloc]initWithNibName:@"infoView" bundle:nil];
    infoViewController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
    [self presentViewController:infoViewController animated:YES completion:nil];