标签栏消失

时间:2013-03-12 12:23:18

标签: ios xcode cocoa-touch uistoryboard tabbarcontroller

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

所以这是设置: 根视图是Tab Bar Controller,它有2个选项卡,View A和View B

视图A在相机完成后启动相机,取消相机,然后转到另一个名为View C的视图,现在标签栏中的视图C

点击时,View C中有一个按钮,它会关闭当前视图并进入视图B. 这是问题:当我尝试从View C加载到View B标签栏消失时。

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

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

由于

修改 这是我在标签之间传递数据的代码:

我如何从视图A调用视图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的按钮也消失了,

1 个答案:

答案 0 :(得分:0)

以下是您如何使用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;
}