1

我最近从 Storyboard 转换为 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];
4

1 回答 1

2

首先,您应该infoView从 Storyboard 转换为infoView.xib,然后:

    infoView *infoViewController = [[infoView alloc]initWithNibName:@"infoView" bundle:nil];
    infoViewController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
    [self presentViewController:infoViewController animated:YES completion:nil];
于 2012-08-16T02:19:14.207 回答