2012-07-03 98 views
0

我是iPhone新手。我有一個小小的懷疑,那就是我創建了一個項目,當我點擊一個按鈕時,它會打開UIWebView那個UIView我想要一個帶有後退按鈕的導航欄,這是可能的。爲此,我寫了一些代碼,但在這裏我不能夠創建回button.If任何身體知道這個請大家幫我... 下面的代碼我已經爲這個如何在導航欄上放置後退按鈕

BiblePlayerViewController.m

- (IBAction)aboutUsButtonClicked:(id)sender { 

     UIWebView *aboutUsWebView = [[UIWebView alloc]initWithFrame:CGRectMake(0,44, 320, 460)]; 
     [self.view addSubview:aboutUsWebView]; 
     [aboutUsWebView setOpaque:NO]; 
     aboutUsWebView.backgroundColor = [UIColor whiteColor]; 
     aboutUsWebView.delegate = self; 

     [aboutUsWebView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.ayansys.com/"]]]; 

     biblePlayerController = [[BiblePlayerViewController alloc]initWithNibName:@"BiblePlayerViewController" bundle:nil]; 

     navigationController = [[UINavigationController alloc]init]; 
     navigationController.view.frame = CGRectMake(0, 0, 320, 44); 
     [self.view addSubview:navigationController.view]; 

     self.navigationController.navigationBar.tintColor=[UIColor orangeColor]; 

     UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithTitle:@"Back" style:UIBarButtonItemStylePlain target:self action:@selector(GotoBiblePlayerViewController)];   

     self.navigationItem.leftBarButtonItem = backButton; 
} 
+0

的可能的複製http://stackoverflow.com/questions/2846539/adding-back-button-to-navigation-bar – Meet

回答

1
[self.navigationController setNavigationBarHidden:NO animated:YES]; 

放寫這在你的viewDidAppear,viewDidLoadviewWillAppear

或本:

UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithTitle:@"Back" style:UIBarButtonItemStyleDone target:nil action:nil]; 
self.navigationItem.backBarButtonItem = backButton;