All I wanted was a simple view controller setup. So when you click on a button it switches to a designated view and appears with a nav controller bar at the top. I would like to do this in a view of a tab bar controller.
I just need to know what connections to make in interface builder for this to work.
I have my speci开发者_JAVA百科fied code in the appdelegates h and m.
My .H
//navigation controller
UINavigationController *navigationController;
//view controller
UIViewController *LibraryVC;
UIViewController *OrganizeVC;
UIViewController *DiscoverVC;
UIViewController *NavigationBarVC;
//buttons
UIButton *LibraryButton;
UIButton *OrganizeButton;
UIButton *DiscoverButton;
@property (nonatomic, retain) IBOutlet UINavigationController *navigationController;
@property (nonatomic, retain) IBOutlet UIViewController *LibraryVC;
@property (nonatomic, retain) IBOutlet UIViewController *OrganizeVC;
@property (nonatomic, retain) IBOutlet UIViewController *DiscoverVC;
@property (nonatomic, retain) IBOutlet UIViewController *NavigationBarVC;
@property (nonatomic, retain) IBOutlet UIButton *LibraryButton;
@property (nonatomic, retain) IBOutlet UIButton *OrganizeButton;
@property (nonatomic, retain) IBOutlet UIButton *DiscoverButton;
-(IBAction)next;
-(IBAction)next2;
-(IBAction)next3;
MY .M
@synthesize navigationController;
@synthesize LibraryVC;
@synthesize OrganizeVC;
@synthesize DiscoverVC;
@synthesize NavigationBarVC;
@synthesize LibraryButton;
@synthesize OrganizeButton;
@synthesize DiscoverButton;
-(IBAction)next{
[navigationController pushViewController:LibraryVC animated:YES];
}
-(IBAction)next2{
[navigationController pushViewController:OrganizeVC animated:YES];
}
-(IBAction)next3{
[navigationController pushViewController:DiscoverVC animated:YES];
}
you can use the same syntax like [self.navigationcontroller pushviewcontroller:controllername animated:YES];
精彩评论