2013-09-23 105 views
2

中推送的視圖控制器中的後退按鈕標題我打開信息屏幕。 一切正常,屏幕打開,標題顯示爲我想,但我不能得到默認的後退按鈕標題更改如何使用下面的代碼使用以下代碼在ios5

我應該怎麼做,在xcode5

感謝

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender 
{ 
    if ([segue.identifier isEqualToString:@"infoRegularSegue"]) 
    { 


     FirstViewController *destViewController = segue.destinationViewController; 
     destViewController.title = NSLocalizedString(@"Information", title of information  view); 

//this code below does not work  
    destViewController.navigationItem.backBarButtonItem.title = @"test"; 

//ive also tried leftbuttonitem 

    } 
} 
+0

add self.navigationItem.backBarButtonItem.title = @「test」;在目標控制器中的viewDidLayoutSubviews函數中的語句,並檢查...我沒有測試它,但它應該工作... – Hindu

+0

抱歉,但這並不工作,或者 – superllanboy

+0

可能重複[在ios中設置標題的back bar按鈕項](http ://stackoverflow.com/questions/17403483/set-title-of-back-bar-button-item-in-ios) –

回答

7

經過大量的搜索和嘗試各種解決方案在這個論壇上,我終於得到了一些工作,我發佈在下面爲其他人的利益卡住在這一點上。

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender 
{ 
    if ([segue.identifier isEqualToString:@"infoRegularSegue"]) 
    { 


     FirstViewController *destViewController = segue.destinationViewController; 
     destViewController.title = NSLocalizedString(@"Information", title of information view); 

     //here is the solution to my problem 
     UIBarButtonItem *backButton = [[UIBarButtonItem alloc]initWithTitle:NSLocalizedString(@"Return", returnbuttontitle) style:  UIBarButtonItemStyleBordered target:nil action:nil]; 
     self.navigationItem.backBarButtonItem = backButton; 

    } 
}