ios - 标签栏消失

标签 ios xcode cocoa-touch uistoryboard tabbarcontroller

我是 iOS 开发的新手,但我遇到了 Controller 问题。我简化了我的问题,让每个人的生活更轻松。

所以这是设置:
Root View 是选项卡栏 Controller ,它有 2 个选项卡, View A 和 View B

View A 在完成摄像头后启动摄像头,关闭摄像头,然后转到另一个名为 View C 的 View ,现在 View C 为 不是 在标签栏中。

单击 View C 中有一个按钮,它会关闭当前 View 并转到 View B。
这是问题所在:当我尝试从 View C 加载到 View B 时,标签栏消失了。

有谁知道如何解决这个问题?

View C 仅在拍照后才有用,因此将其添加到标签栏不是解决方案。

谢谢

编辑:
这是我如何在选项卡之间传递数据的代码:

我如何从 View A 调用 View C:

[self dismissViewControllerAnimated:YES completion:
 ^{
     UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPhone" bundle:nil];
     ViewControllerA *A = [storyboard instantiateViewControllerWithIdentifier:@"ViewControllerA"];
     A.data1 = data1; 
     A.data2 = data2; 
     A.image = image; 
     [self presentViewController:A animated:YES completion:nil];
 }];

我如何从 View C 调用 View B:
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender

{
if([segue.identifier isEqualToString:@"toViewB"]) {

    SomeClass *obj = [[SomeClass alloc] init];
    [obj setData1: _data1];
    [obj setData2: _data2.text];
    [obj setImage: _image];


    ViewControllerB *B = (ViewControllerB *)segue.destinationViewController;
    B.newObj = obj;
    [B createCell];
}

}

我还想提一下,我添加到 ViewB 的按钮也消失了,

最佳答案

以下是如何使用 UITabBarController 的简单示例

第一创建UIViewController的所有对象和 UINavigationControllerAppDelegate.h归档并使用AppDelegate.m的以下方法

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window=[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds ]];

    self.viewCon=[[ViewController alloc] init];
    self.navCon=[[UINavigationController alloc] initWithRootViewController:self.viewCon];
    self.navCon.navigationBar.tintColor=[UIColor blackColor];
    self.viewCon.title=@"First View";

    self.fView=[[FirstViewController alloc] init];
    self.FnavCon=[[UINavigationController alloc] initWithRootViewController:self.fView];
    self.FnavCon.navigationBar.tintColor=[UIColor blackColor];

    self.fView.title=@"Secound View";

    self.sView=[[SecoundViewController alloc] init];
    self.SnavCon=[[UINavigationController alloc] initWithRootViewController:self.sView];
    self.SnavCon.navigationBar.tintColor=[UIColor blackColor];
    self.sView.title=@"Third View";
    .
    .
    // create UIViewController and UINavigationController As you need 
    .
    .
    .
    UIImage *img1=[UIImage imageNamed:@"Australia.gif"];
    self.tbItem1=[[UITabBarItem alloc] initWithTitle:@"First Page" image:img1 tag:1];
    self.viewCon.tabBarItem=self.tbItem1;

    UIImage *img2=[UIImage imageNamed:@"Cameroon.gif"];
    self.tbItem2=[[UITabBarItem alloc] initWithTitle:@"Secound Page" image:img2 tag:2];
    self.fView.tabBarItem=self.tbItem2;

    UIImage *img3=[UIImage imageNamed:@"Canada.png"];
    self.tbItem3=[[UITabBarItem alloc] initWithTitle:@"Third Page" image:img3 tag:3];
    self.sView.tabBarItem=self.tbItem3;

    NSMutableArray *viewArr=[[NSMutableArray alloc] init];
    [viewArr addObject:self.navCon];
    [viewArr addObject:self.FnavCon];
    [viewArr addObject:self.SnavCon];


    self.tbCon=[[UITabBarController alloc] init];
    self.tbCon.viewControllers=viewArr;

    [self.window addSubview:tbCon.view];

    [self.window makeKeyAndVisible];

    return YES;
}

关于ios - 标签栏消失,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15361093/

相关文章:

ios - iOS 中的 AES/CBC/PKCS5Padding objective-c 结果与 Android 不同

iphone - 为每个新的 NSOperation 或线程创建一个新的 NSManagedObjectContext 是否足够?

ios - 升级到 Xcode 7.1 - "Google Mobile Ads"找不到框架

ios - 如何正确关闭模态呈现的 Controller

ios - 如何将自定义项目添加到导航栏

ios - IBAction 函数已正确连接但未执行

xcode - 未使用MonoTouch创建的 View Controller 的头文件

ios - 获取细胞索引-偷看和流行

iphone - 如何在构建时测试 UIViewController?

iphone - 由于未捕获的异常“NSInternalInconsistencyException”而终止应用程序,原因:“错误:无法打开数据库并显示消息“不是错误”。