2013-03-12 79 views
2

我是iOS開發新手,遇到控制器問題。我簡化了我的問題,讓每個人的生活更輕鬆。Tab Bar消失

所以這裏的設置: 的根視圖是標籤欄控制器,它有2個選項卡,查看A和視圖B它用相機進行後

觀啓動相機,駁回了相機,然後去到另一個稱爲視圖C的視圖,現在視圖C在標籤欄中是而不是

視圖C中有一個按鈕,點擊它將取消當前視圖並轉到視圖B. 問題出在這裏:當我嘗試從視圖C加載到視圖B標籤欄時消失。

有誰知道如何解決這個問題?

視圖C僅在拍攝照片後纔有用,因此將其添加到選項卡欄不是解決方案。

感謝

編輯: 這裏是我如何在標籤之間傳遞數據的代碼:

如何調用視圖C從View答:

[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]; 
}]; 

如何從視圖C調用視圖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按鈕也消失了,

+0

方法告訴你的代碼,你是如何將項目添加到TabBar,所以你是如何顯示搜索C&貶? – nsgulliver 2013-03-12 12:29:42

回答

0

以下是對如何使用UITabBarController

簡單的例子

首先創建UIViewControllerUINavigationController的所有對象AppDelegate.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]; 
    [email protected]"First View"; 

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

    [email protected]"Secound View"; 

    self.sView=[[SecoundViewController alloc] init]; 
    self.SnavCon=[[UINavigationController alloc] initWithRootViewController:self.sView]; 
    self.SnavCon.navigationBar.tintColor=[UIColor blackColor]; 
    [email protected]"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; 
} 
相關問題