2012-04-23 71 views
1

我是很新,Objective-C的,所以我提前很抱歉,如果我失去了一些東西,你會考慮明顯:)使用ABPersonViewController的正確方法?

我寫了一個簡單的程序來顯示通訊簿,並選擇用戶(模仿iOS聯繫人列表)。

我有一個基本的控制器:

@interface BasicViewController : 
UIViewController<ABPersonViewControllerDelegate> 

控制器從先前視圖臨危一個ABRecordRef。 在我的方法之一,我用:

ABPersonViewController* ctrl = [[ABPersonViewController alloc]init]; 

ctrl.allowsEditing = NO; 
[ctrl setPersonViewDelegate:self]; 
[ctrl setDisplaydPerson:person]; 

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

當我到了實際的看法,我得到了一個空白的屏幕(與一個ABPersonView相關背景)。 我撥弄了一下與displayedProperties:

ctrl.displayedProperties = [NSArray arraywithObjects: 
    [NSNumber numberWithInt:kABPersonLastNameProperty],nil]; 

當我指定我只是想看到最後的名字 - 消息出現 上了同樣的觀點 - NO_VALUE_UNKNOWN

我在調試檢查,我ABRecordRef不爲空,幷包含所有相關的字符串。

任何想法?

回答

2

解決了它:) 我調用了一個包含從segue上面顯示的代碼的方法。 超級的viewDidLoad方法直到我的方法被調用之後才被調用。

,當我重新排列調用順序,它的工作就像一個魅力:)