1

I use this tutorial to achieve my custom UITabBarController: link

But I use storyboard instead of xibs. So some of method use this code below:

NSArray *nibObjects = [[NSBundle mainBundle] loadNibNamed:@"TabBarView" owner:self options:nil];

It is fair for xib but as I think not for storyboard.

4

2 回答 2

1

恐怕故事板不太适合这种任务。没有从UIStoryboard实例中获取特定视图的方法。

在这种情况下,我建议您创建一个单独的 xib 文件,其中仅包含您要自行加载的视图,并使用您提供的代码来加载它。

附带说明一下,我也不建议使用自上次提交以来已有 3 年的库,特别是在 iOS 7 中,它会破坏很多东西。

于 2013-10-30T11:51:24.380 回答
1

这对你有用

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"StoryboardName" bundle:nil];
UIViewController *initViewController = [storyboard instantiateViewControllerWithIdentifier:@"ViewControllerName"];

不要忘记在情节提要中为您的视图控制器提供标识符。

注意:-确保您已ViewControllerWithIdentifier在情节提要中给出。

于 2013-10-30T11:28:14.683 回答