2013-04-02 88 views
0

我想改變一些聯繫人表的屬性,但我不能。 首先,我需要刪除取消按鈕,並設置一個「添加」按鈕。我已經嘗試使用委託方法將其設置爲零,但它沒有奏效。更改ABPeoplePickerNavigationController屬性

它做的工作的唯一方法是這樣的:

[picker setAllowsCancel:NO]; 

這給出了一個警告:(我不想採取與風險)

instance method not found 

我還需要刪除「組」按鈕。

所以在底線,我想從上面的欄中刪除所有按鈕,並設置我自己的按鈕。我會怎麼做?

謝謝。

回答

0

誇大其詞,不要去碰使用方法:

[picker setAllowsCancel:NO]; 

它是蘋果的私有的API(非公開),他們會拒絕你的應用程序。

ABPeoplePickerNavigationController *tempABPNC = [[ABPeoplePickerNavigationController alloc] init]; 
tempABPNC.peoplePickerDelegate = self; 
tempABPNC.delegate = self; 
[self presentModalViewController:tempABPNC animated:YES]; 
[tempABPNC release]; 

您必須添加 「tempABPNC.delegate =自我;」 再執行UINavigationControllerDelegate方法:

- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated{ 
viewController.title = @"選擇聯繫人"; 
tinlnTempVC = viewController; 
viewController.navigationItem.leftBarButtonItem = nil; 
UIViewController *tempABVC = [navigationController.viewControllers lastObject]; 
tempABVC.title = @"選擇聯繫人"; 
if([viewController.view.subviews count]==0){ //if user disable app open contact,you can create your own view, 
    UIView *tempV=[[UIView alloc]initWithFrame:CGRectMake(0, 0, 320, IS_IPHONE5 ? 504 : 416)]; 
    ... 
    ... 
    viewController.view = tempV; 
    [tempV release]; 
}} 

在這個視圖 - 控制,子類的ABPeoplePickerNavigationController,所以我們可以用我們自己的按鈕替換navigationleft,右,backitem

static UIViewController *tinlnTempVC; 
@implementation ABPeoplePickerNavigationController (tinlnCustom) 

- (void)viewWillLayoutSubviews{ 
if ([[[UIDevice currentDevice] systemVersion] floatValue] < 5.0) 
    return; 
UIButton *dismisBtn = [UIButton DIYNavigationBarItemBtnWithTitle:@"返 回" NC:tinlnTempVC.navigationItem]; 
[dismisBtn addTarget:self action:@selector(backToPayPhone) forControlEvents:UIControlEventTouchUpInside];} 

- (void)backToPayPhone{ 
[self dismissModalViewControllerAnimated:YES];} 


@end 

的希望幫助你,咆哮,這種方法的iOS 5.0-6.1運行完美,在iOS的4.3-5.0的backitem水溼在第t更換ime show。