2011-08-30 3 views
1

나는 SettingView1과 SettingView2 사이를 뒤집을 수있는 TabBar로 SettingViewMain을 갖고 싶습니다.다른보기에 대한보기의 간단한 TabBar?

3 시간이 간단한 작업을 시도하고 거의 모든 자습서를 시도했지만 작동하지 않습니다.

프로그래밍 방식으로 TabBar를 추가하려고하면이 2 개의보기를 전환 할 수 있지만이보기 자체에서는 TabBar가 표시되지 않고 이유를 모르겠습니다. TabBarController를 추가하면 이것이 전혀 표시되지 않습니다.

그래서 simlpy : 어떻게 AppBelegate-Window 나 이와 비슷한 것이 아닌 MasterView에 TabBar를 추가하고 TabBar에서 View1과 View2 사이를 전환합니까?

답변

2

alloc 및 init 메소드를 사용하여 UITabBarController를 인스턴스화 할 수 있습니다. 두 개의 다른 ViewController를 인스턴스화하고 배열에 추가합니다. 그런 다음 'MasterView'에보기를 추가하십시오.

코드 :

UITabBarController *tab = [[UITabBarController alloc] init]; 
UIViewController *controller1 = [[UIViewController alloc] init]; 
UIViewController *controller2 = [[UIViewController alloc] init]; 

NSArray *controllers = [[NSArray alloc] initWithObjects:controller1, controller2, nil]; 
[tab setViewControllers:controllers]; 

[[self view] addSubview:[tab view]]; 

또는 뭔가 면밀히 비교.

행운을 빈다.

브라이언