0

iOS開発初心者です。私のプロジェクトへのリンクを添付して、誰かが私を助けてくれることを願っています。4 つの項目 (ホーム、会社概要、お問い合わせ、Safari で開く Web サイトへのリンク) を含むタブ バーを追加する必要があります。いくつかの例外を除いて、同じ 3 つのアイテムがすべてのビューに表示されます。「ホーム」画面にはホーム アイテムは必要ありません。私たちについてのページにはそのアイテムは必要ありません。また、お問い合わせにもそのアイテムは必要ありません。

また、各ビューに戻るボタンがあり、そのページのタイトルを表示するナビゲーション バーも必要です。

ここに私のプロジェクトへのリンクがあります: https://www.dropbox.com/s/sv0y3oh1aftxl95/KFBNewsroom%204.zip

前もって感謝します!

4

2 に答える 2

0

以下のコードは、問題を解決するのに役立ちます

// set up a local nav controller which we will reuse for each view controller
UINavigationController *localNavigationController;

// create tab bar controller and array to hold the view controllers
UITabBarController *tabBarController = [[UITabBarController alloc] init];

NSMutableArray *localControllersArray = [[NSMutableArray alloc] initWithCapacity:1];

// setup the first view controller (Root view controller)
RootViewController *myViewController;
myViewController = [[RootViewController alloc] initWithTabBar];

// create the nav controller and add the root view controller as its first view
localNavigationController = [[UINavigationController alloc] initWithRootViewController:myViewController];
localNavigationController.navigationBar.barStyle = UIBarStyleBlack;
localNavigationController.delegate = self;

[localControllersArray addObject:localNavigationController];

// release since we are done with this for now
[localNavigationController release];
[myViewController release];

tabBarController.viewControllers = localControllersArray;
tabBarController.moreNavigationController.navigationBar.barStyle = UIBarStyleBlack;  

tabBarController.delegate = self;
tabBarController.moreNavigationController.delegate = self;

// release the array because the tab bar controller now has it
[localControllersArray release];

self.tabBarController.selectedIndex = 0;

// add the tabBarController as a subview in the window
self.window.rootiviewcontroller = self.tabbarcontroller;

//ウィンドウ(およびタブバーコントローラー)を表示するには、この最後の行が必要です[window makeKeyAndVisible];

于 2012-11-02T13:43:29.377 に答える
0

ビューコントローラーをタブバーに直接プッシュする代わりに、最初にナビゲーションコントローラーを作成し、特定のコントローラーのルートビューコントローラーで初期化します

Settings *settingsVC = [[Settings alloc] init];
UINavigationController *settingsNavigationController = [[UINavigationController alloc] initWithRootViewController:settingsVC];
Report *reportVC = [[Report alloc] init];
UINavigationController *reportNavigationController = [[UINavigationController alloc] initWithRootViewController:reportVC];
Episodes *episodesVC = [[Episodes alloc] init ];
UINavigationController *episodesNavigationController = [[UINavigationController alloc] initWithRootViewController:episodesVC];
UINavigationController *homeNavigationController = [[UINavigationController alloc] initWithRootViewController:homeVC];

NSArray* controllers = [[NSArray alloc] initWithObjects:settingsNavigationController,
                               reportNavigationController,
                               episodesNavigationController,
                               homeNavigationController, nil];
于 2012-11-02T13:51:48.920 に答える