我一直在讀一點我想弄清楚如何爲我的應用程序創建適當的視圖層次結構。我使用arc在xcode 4.2中創建了一個基本Tabbed應用程序,但是這個新應用程序不包含mainwindow.xib,所以很多使用IB的教程對我來說都是毫無用處的。我有一個5選項卡應用程序已經工作,應用程序的「基礎」按預期工作。我需要的是在當前正在查看的特定「標籤」窗口中包含更多視圖。我的思維很簡單,如下所示。我的猜測是有問號加入我只有5個基類,所有當前的tabBarControllerxcode 4.2選項卡式應用程序Heriarcy
應用heriarchy(建議)
Home (Currently UIViewController using homeViewController, convert to UINavigationController?)
Add (UIViewController with HomeAdd.xib?)
Edit (UIViewController with HomeEdit.xib
delete (UIViewController with HomeDelete.xib?)
ViewList - Single page to view list (Currently UIViewController using viewListViewController)
Share - Single page to send emails/invites (Currently UIViewController using shareViewController)
Friends (UINavigationController with root view of FriendsRoot.xib?)
Add (UIViewController with FriendsAdd.xib?)
Edit (UIViewController with FriendsEdit.xib?)
delete (UIViewController with FriendsDelete.xib?)
Settings - Single page for app settings/preferences (Currently UIViewController using settingsViewController)
內UIViewControllers我甚至不知道,如果上述層次結構是可能的(即在tabBarController中混合視圖控制器),並且會喜歡關於如何以編程方式完成這個輸入,因爲這似乎是我在應用程序委託中的唯一選項,因爲默認情況下沒有mainwondiw.h/m/xib。爲此我的應用程序委託中
我當前的代碼如下:
AppDelegate.h
#import <UIKit/UIKit.h>
@interface AppDelegate : UIResponder <UIApplicationDelegate, UITabBarControllerDelegate>
@property (strong, nonatomic) UIWindow *window;
@property (strong, nonatomic) UITabBarController *tabBarController;
@end
AppDelegate.m
@synthesize window = _window;
@synthesize tabBarController = _tabBarController;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
UIViewController *homeViewController = [[HomeViewController alloc] initWithNibName:@"HomeViewController" bundle:nil];
UIViewController *viewListViewController = [[ViewListViewController alloc] initWithNibName:@"ViewListViewController" bundle:nil];
UIViewController *shareViewController = [[ShareViewController alloc] initWithNibName:@"ShareViewController" bundle:nil];
UIViewController *friendsViewController = [[FriendsViewController alloc] initWithNibName:@"FriendsViewController" bundle:nil];
UIViewController *settingsViewController = [[SettingsViewController alloc] initWithNibName:@"SettingsViewController" bundle:nil];
self.tabBarController = [[UITabBarController alloc] init];
[self.tabBarController setDelegate:self];
self.tabBarController.viewControllers = [NSArray arrayWithObjects:homeViewController, viewListViewController, shareViewController, friendsViewController, settingsViewController, nil];
self.window.rootViewController = self.tabBarController;
[self.window makeKeyAndVisible];
return YES;
}
我已經嘗試了一些嘗試注入UINavigationControllers ,或者使用自定義按鈕替代視圖,但所有這些都會導致構建失敗,因爲我仍在學習上下文和代碼。
任何建議將apprecaited。我以前的帖子迄今爲止取得了有限的成功。
謝謝
銀虎
我同意..但每次我用XCode 4.2創建一個「標籤」應用程序時,它創建了應用程序委託文件,但沒有默認的xib ...我認爲這也很奇怪。我會嘗試和研究模態觀點,看看如何實現這些,如果你有任何非IB代碼我可以使用,我寧願在依賴IB之前學習它。 – Silvertiger
另外,我可以使用我自己的按鈕來切換視圖(即家裏有3個自定義按鈕,會推...?模態視圖,如果我這樣做,它仍然會有標籤欄?看看我可以找到關於模態視圖的互聯網:) – Silvertiger
好的..我發現一個頁面,解釋得很好(有一些調整)如何實現一個模態視圖,我已經得到它我工作的火焰...該頁面是「http://timneill.net/2010/09/modal-view-controller-example-part-1/」 - 只要我能做到這一點深層次,我很好: )...感謝您的指導。 – Silvertiger