2013-03-29 65 views
1

我有三個viewController v1 v2 v3,從v1到v2我使用導航控制器的pushViewController屬性,但是從v2到v3我使用presentviewController。在v3我需要導航欄與右側的按鈕,以便我可以執行方法。 plesae幫助。在現有項目中添加導航欄

+0

創建自定義導航吧然後。 – rptwsthi

+0

沒有自定義進程,不可能, – Youaregreat

+0

然後在v3中進行自定義進程。 – rptwsthi

回答

2

在視圖控制器V2,使用以下代碼來出示V3

V3 *obj_V3=[[V3 alloc]initWithNibName:@"V3" bundle:nil]; 
UINavigationController *navBar=[[UINavigationController alloc]initWithRootViewController:obj_V3]; 
[self.navigationController presentModalViewController:navBar animated:YES]; 
[navBar release]; 
[obj_V3 release]; 

和在V3添加

self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(performMethod)] autorelease]; 

和您的執行方法

-(void)performMethod { 
//your code 
} 
+1

謝謝crimeMaster Gogogo,你已經採取了我的代碼犯罪並提供解決方案令人驚歎 – Youaregreat