2014-09-25 88 views
0

我的應用程序現在是comatible只與iOS 7和iOS 8,我有這種方法的一個問題:navigationController:willShowViewController:動畫:問題

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

這只是叫的iOS 7,文檔不要t說thas在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> 
{ 
    ... 
} 
+0

該代碼在哪裏以及該對象如何成爲導航控制器的代表? – matt 2014-09-25 15:52:30

+0

你好馬特,我已經添加了更多的代碼來澄清我的問題。謝謝... – human4 2014-09-25 19:08:16

回答

1

問題是你沒有設置ABPeoplePickerNavigationController的delegate(UINavigationControllerDelegate)。您正在設置其pickerDelegate(ABPeoplePickerNavigationControllerDelegate),但這不是一回事。

+0

非常感謝我添加了這一行: 'contactos.delegate = pickerDelegate;' – human4 2014-09-25 19:18:21