2011-05-25 158 views
0

我只想要一個簡單的視圖控制器設置。所以當你點擊一個按鈕時,它會切換到一個指定的視圖,並在頂部顯示一個導航控制欄。我想在標籤欄控制器的視圖中執行此操作。簡單的視圖控制器幫助

我只需要知道在界面生成器中爲了使其工作而建立的連接。

我在appdelegates h和m中指定了我的代碼。

我.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]; 
} 

回答

0

您可以使用相同的語法類似[self.navigationcontroller pushviewcontroller:controllername動畫:YES];

+0

我只需要知道連接 – supermonkey 2011-05-26 20:09:46