在Tag Bar中使用Navgation
前面分别学到了Tag Bar和Navigation的使用,这次我们把他合起来使用,效果如下图


首先创建项目,选择window based application。项目名称为Nav_Tagbar。在.h中完成代码
#import <UIKit/UIKit.h>@interface Nav_TagbarAppDelegate : NSObject <UIApplicationDelegate> { UIWindow *window;UITabBarController *rootController;}@property (nonatomic, retain) IBOutlet UIWindow *window;@property (nonatomic, retain) IBOutlet UITabBarController *rootController;@end#import "Nav_TagbarAppDelegate.h"@implementation Nav_TagbarAppDelegate@synthesize window;@synthesize rootController;#pragma mark -#pragma mark Application lifecycle- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { [window addSubview:rootController.view]; [window makeKeyAndVisible]; return YES;}- (void)dealloc {[rootController release]; [window release]; [super dealloc];}@end


#import <UIKit/UIKit.h>@interface navView : UIViewController {}-(IBAction)buttonPressed;@end#import "navView.h"#import "thirdView.h"@implementation navView-(IBAction)buttonPressed{thirdView *mythirdView = [[thirdView alloc] initWithNibName:@"thirdView" bundle:nil];[self.navigationController pushViewController:mythirdView animated:YES];[mythirdView release];}