2013-04-02 50 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。