2010-08-15 87 views
1

我有一個基於「基於導航的應用程序」項目類型的簡單項目。 RootViewController有一個包含聯繫人姓名的行列表,以及一個按鈕,它應該將他們帶到ABPersonViewController的聯繫人詳細信息頁面。ABPersonViewController ...沒有後退按鈕

我有所有的掛鉤工作,我通過推導向導航堆棧顯示正確的ABPersonViewController ...但它沒有Back按鈕!該應用程序被卡住,因爲沒有辦法回到我的應用程序。如何啓用後退按鈕?希望得到一些幫助。

下面是相關代碼:

- (void) nameButtonClicked: (id) sender 
{ 
    UIButton *button = (UIButton *) sender; 
    NSLog(@"name button clicked... record_id = %i", button.tag); 
    ABRecordRef contact_data = ABAddressBookGetPersonWithRecordID(address_book, button.tag); 

    ABPersonViewController *ab = [[ABPersonViewController alloc] init]; 
    [ab setPersonViewDelegate:self]; 
    [ab setDisplayedPerson:contact_data]; 
    ab.allowsEditing = YES; 
    [self.navigationController pushViewController:ab animated:YES]; 
    [ab release]; 
} 

回答

2

如果你不能找到系統後退按鈕你總是可以自己創建。

- (void) nameButtonClicked: (id) sender 
{ 
UIButton *button = (UIButton *) sender; 
NSLog(@"name button clicked... record_id = %i", button.tag); 
ABRecordRef contact_data = ABAddressBookGetPersonWithRecordID(address_book, button.tag); 

ABPersonViewController *ab = [[ABPersonViewController alloc] init]; 
ab.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Back",nil) style:UIBarButtonItemStyleDone target:self action:@selector(ReturnFromPersonView)]; 
[ab setPersonViewDelegate:self]; 
[ab setDisplayedPerson:contact_data]; 
ab.allowsEditing = YES; 
[self.navigationController pushViewController:ab animated:YES]; 
[ab release]; 
} 

- (void)ReturnFromPersonView{ 
[self.navigationController popViewControllerAnimated:YES]; 
} 

好運氣=]

btw-如果你不喜歡的「完成」按鈕樣式,你可以隨時使用的自定義按鈕樣式後退按鈕箭頭般的外觀。