我有如下要求,如在基於tabbar的應用程序中顯示ABPeoplePickerNavigationController。我在網上研究了很多,發現沒有有用的答案,但一個here,實現代碼如下所示,將有助於在tabbar中獲取ABPeoplePickerNavigationController,如圖所示。基於Tabbar的應用程序中的ABPeoplePickerNavigationController
第一次截圖是我運行應用程序時的直接結果,第二次截圖是當我再次點擊聯繫人選項卡(奇怪但那是真的)。現在
-(void)awakeFromNib
{
ABPeoplePickerNavigationController *nav = [[ABPeoplePickerNavigationController alloc] init];
NSMutableArray *newControllers = [NSMutableArray arrayWithArray: [self.tabBarController viewControllers]];
int index = [newControllers indexOfObject: self];
[newControllers replaceObjectAtIndex: index withObject: nav];
[self.tabBarController setViewControllers: newControllers animated: NO];
[nav release];
}
我的問題是,我能夠通過接觸來瀏覽,但不能設置的ABPeoplePickerNavigationController委託。我想重寫以下代理方法
-(BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifier
{
}
-(BOOL)peoplePickerNavigationController: (ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person
{
}
我不能設置,因爲我不知道在哪裏設置委託。請幫助我,因爲我的項目在截止日期,所有其他功能都已完成。
歡迎任何竅門。我假設我可以繼承ABPeoplePickerNavigationController並做一些事情,但不知道該怎麼做。
編輯 設置委託後,我收到以下崩潰時,我點擊聯繫人選項卡。
#0 0x00f85057 in ___forwarding___
#1 0x00f84f22 in __forwarding_prep_0___
#2 0x00d4b678 in -[ABMembersViewController membersController:shouldAllowSelectingPerson:]
#3 0x00d1df85 in -[ABMembersController abDataSource:shouldAllowSelectingPerson:]
#4 0x00d9abb9 in -[ABMembersDataSource tableView:cellForRowAtIndexPath:]
#5 0x003357fa in -[UITableView(UITableViewInternal) _createPreparedCellForGlobalRow:withIndexPath:]
#6 0x0032b77f in -[UITableView(UITableViewInternal) _createPreparedCellForGlobalRow:]
#7 0x00340450 in -[UITableView(_UITableViewPrivate) _updateVisibleCellsNow:]
#8 0x00338538 in -[UITableView layoutSubviews]
#9 0x01dc8451 in -[CALayer layoutSublayers]
#10 0x01dc817c in CALayerLayoutIfNeeded
#11 0x01dc137c in CA::Context::commit_transaction
#12 0x01dc10d0 in CA::Transaction::commit
#13 0x01df17d5 in CA::Transaction::observer_callback
#14 0x00ff4fbb in __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__
#15 0x00f8a0e7 in __CFRunLoopDoObservers
#16 0x00f52bd7 in __CFRunLoopRun
#17 0x00f52240 in CFRunLoopRunSpecific
#18 0x00f52161 in CFRunLoopRunInMode
#19 0x018b5268 in GSEventRunModal
#20 0x018b532d in GSEventRun
#21 0x002d042e in UIApplicationMain
#22 0x00002240 in main at main.m:13
Thax。我實現爲nav.peoplePickerDelegate = self;但我碰到像這個問題的應用程序崩潰http://stackoverflow.com/questions/7068848/ios-devproblem-uimorenavigationcontroller-and-abpeoplepickernavigationcontroller –
如果我不設置委託工作正常,但委託方法不會被調用,因爲它是沒有設置。 –