navigationController:willShowViewController:animated:issue

时间:2014-09-25 15:48:02

标签: objective-c iphone ios8

我的应用程序现在只能与iOS 7和iOS 8兼容,我对此方法有疑问:

-(void)navigationController:(UINavigationController *)navigationController 
    willShowViewController:(UIViewController *)viewController 
    animated:(BOOL)animated
{
     ...
}

这仅在iOS 7中调用,文档并未说明在iOS 8或其他版本中已弃用。有什么不对,有什么想法吗?

我在小牛队中使用xcode版本6.0.1(6A317)

我在另一个类中声明了委托:

ABPeoplePickerNavigationController *contactos = [[ABPeoplePickerNavigationController alloc] init];
contactos.displayedProperties = [NSArray arrayWithObject:[NSNumber numberWithInt:kABPersonPhoneProperty]];

// Delegate
pickerDelegate = [[PickerDelegate alloc] init];
contactos.peoplePickerDelegate  = pickerDelegate;
contactos.topViewController.navigationController.delegate = pickerDelegate;

PickerDelegate.h:

#import <Foundation/Foundation.h>
#import <AddressBook/AddressBook.h>
#import <AddressBookUI/AddressBookUI.h>

@interface PickerDelegate : NSObject <UINavigationControllerDelegate, ABPeoplePickerNavigationControllerDelegate, ABPersonViewControllerDelegate, ABNewPersonViewControllerDelegate>
{
    ...
}

1 个答案:

答案 0 :(得分:1)

问题是你没有设置ABPeoplePickerNavigationController的delegate(UINavigationControllerDelegate)。您正在设置其pickerDelegate(ABPeoplePickerNavigationControllerDelegate),但这不是同一件事。