2011-05-20 27 views
0
ABUnknownPersonViewController *unknownPersonViewController = [[ABUnknownPersonViewController alloc] init]; 

unknownPersonViewController.view.frame = CGRectMake(0, 20, 320, 400); 

//unknownPersonViewController.displayedPerson = (ABRecordRef)[self buildContactDetails]; 
unknownPersonViewController.allowsAddingToAddressBook = YES; 

UIButton *cancelBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect]; 
cancelBtn.frame = CGRectMake(262, 6, 54,30); 
[unknownPersonViewController.view addSubview:cancelBtn]; 

[self presentModalViewController:unknownPersonViewController animated:YES]; 

[unknownPersonViewController release]; 

我使用的UIViewController,並在此代碼我想,像導航條酒吧將在這個控制器上 側顯示,所以我想將取消對bar.any幫助按鈕添加導航欄?在ABUnknownPersonViewController

回答

2

你應該做的是嵌入您ABUnknownPersonViewController在一個UINavigationController

UINavigationController *newNavigationController = [[UINavigationController alloc] initWithRootViewController:unknownPersonViewController]; 

[self presentModalViewController:newNavigationController animated:YES]; 
[view release]; 

[newNavigationController release]; 

這樣,你甚至不必將自己添加按鈕,ABUnknownPersonViewController會照顧它。

欲瞭解更多信息檢查Address Book Programming

0

嗯,在線文檔中說「重要的未知的人視圖控制器必須與導航控制器使用才能正常工作。」因此,不像很多實用程序視圖控制器的,我不認爲你應該調用

[self presentModalViewController:unknownPersonViewController animated:YES]; 

反倒是

[self.navigationController pushViewController:view animated:YES]; 

我認爲,如果你看看他們的樣,你會看到他們使用導航控制器推送。

相關問題