ios - 切换 View 时 presentViewController 不加载标签栏

标签 ios xcode cocoa-touch

当我从 designworks.xib(designworks.m、designworks.h)切换到 MainStoryboard FirstViewController(这是一个选项卡栏 Controller ,选项卡外的第一个 Controller )时,它会加载 Storyboard上的内容,但不会加载底部的标签栏导航。

- (IBAction)backToHome:(id)sender {
    /*
    FirstViewController *fvc = [[FirstViewController alloc] initWithNibName:nil bundle:nil];
    [self presentViewController:fvc animated:YES completion:nil];
     */
    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
    FirstViewController *fvc = [storyboard instantiateViewControllerWithIdentifier:@"FirstViewController"];
    fvc.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
    [self presentViewController:fvc animated:YES completion:nil];
}

最佳答案

检查你是否这样做过

将 View Controller 添加到 tabbarcontroller。

确保您已将此添加到您的 .h 文件中

@property (nonatomic, strong) UITabBarController *tabController;

在您的 .m 文件中合成 tabController 和

FirstViewController *fistView = [[FirstViewController alloc] initWithNibName:@"FirstViewController" bundle:nil];
SecondViewController *secondView = [[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil];
ThirdViewController *thirdView = [[ThirdViewController alloc] initWithNibName:@"ThirdViewController" bundle:nil];

NSArray *viewControllersArray = [[NSArray alloc] initWithObjects:fistView, secondView, thirdView, nil];

self.tabController = [[UITabBarController alloc] init];
[self.tabController setViewControllers:viewControllersArray animated:YES];

现在将其呈现为模态

[self presentViewController:self.tabController animated:YES completion:nil];

关于ios - 切换 View 时 presentViewController 不加载标签栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15924706/

相关文章:

ios - 在哪里存储局部变量? NSKeyedArchiver 还是 NSUserDefaults?

ios - 无法在 Xcode 中将 "Team"设置为 "None"

iphone - 将音频和视频转换为 NSData

objective-c - 在 Objective-C 中创建文件

iOS:从照片库打开图像

ios - 使用 PayPal iOS 库会导致我的应用被拒绝吗?

ios - Xamarin.iOS 中的 UITableViewController.RowsInSection(UITableView, int) 应该是什么?

ios - UI 单元测试卡在 "Waiting for accessibility to load"

ios - 在 UICollectionView 中,我如何预加载 cellForItemAtIndexPath 之外的数据以在其中使用?

android - 使用地理定位 api cordova/phonegap 查找距离、速度和加速度