在presentviewcontroller中,ABPeoplePickerNavigationController崩溃了

时间:2014-01-16 07:30:52

标签: ios

有人帮我解决了这个崩溃问题。我无法找到它的根本原因。

ABPeoplePickerNavigationController *picker = [[ABPeoplePickerNavigationController alloc] init];
    [self presentViewController:picker animated:YES completion:nil];

我遇到了下面的崩溃,不知道为什么,

-[ABPeoplePickerNavigationController masterViewController]: unrecognized selector sent to instance 0xdd8cd40

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[ABPeoplePickerNavigationController masterViewController]: unrecognized selector sent to instance 0xdd8cd40'
*** First throw call stack:
(
    0   CoreFoundation                      0x03b5e5e4 __exceptionPreprocess + 180
    1   libobjc.A.dylib                     0x031f28b6 objc_exception_throw + 44
    2   CoreFoundation                      0x03bfb903 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275
    3   CoreFoundation                      0x03b4e90b ___forwarding___ + 1019
    4   CoreFoundation                      0x03b4e4ee _CF_forwarding_prep_0 + 14
    5   UIKit                               0x0271f544 -[UISearchDisplayController _areSearchContentsSplitViewMaster] + 63
    6   UIKit                               0x0271f6ac -[UISearchDisplayController _configureNewSearchBar] + 307
    7   UIKit                               0x0271ee63 -[UISearchDisplayController initWithSearchBar:contentsController:searchResultsTableViewStyle:] + 121
    8   UIKit                               0x0271ede5 -[UISearchDisplayController initWithSearchBar:contentsController:] + 55
    9   AddressBookUI                       0x03dffe5e -[ABMembersController contentView] + 1223
    10  AddressBookUI                       0x03e05d3e -[ABMembersViewController updateView] + 57
    11  AddressBookUI                       0x03e058b0 -[ABMembersViewController loadView] + 36
    12  UIKit                               0x0249d73e -[UIViewController loadViewIfRequired] + 78
    13  UIKit                               0x024c31a5 -[UINavigationController _layoutViewController:] + 39
    14  UIKit                               0x024c36bb -[UINavigationController _updateScrollViewFromViewController:toViewController:] + 235
    15  UIKit                               0x024c37b3 -[UINavigationController _startTransition:fromViewController:toViewController:] + 78
    16  UIKit                               0x024c472c -[UINavigationController _startDeferredTransitionIfNeeded:] + 645
    17  UIKit                               0x024c5349 -[UINavigationController __viewWillLayoutSubviews] + 57
    18  UIKit                               0x025fe39d -[UILayoutContainerView layoutSubviews] + 213
    19  UIKit                               0x024c1592 __53-[UINavigationController setNeedsDeferredTransition:]_block_invoke + 45
    20  UIKit                               0x023a6d33 ___afterCACommitHandler_block_invoke + 15
    21  UIKit                               0x023a6cde _applyBlockToCFArrayCopiedToStack + 403
    22  UIKit                               0x023a6b0a _afterCACommitHandler + 532
    23  CoreFoundation                      0x03b2653e __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 30
    24  CoreFoundation                      0x03b2648f __CFRunLoopDoObservers + 399
    25  CoreFoundation                      0x03b043b4 __CFRunLoopRun + 1076
    26  CoreFoundation                      0x03b03b33 CFRunLoopRunSpecific + 467
    27  CoreFoundation                      0x03b0394b CFRunLoopRunInMode + 123
    28  GraphicsServices                    0x04df39d7 GSEventRunModal + 192
    29  GraphicsServices                    0x04df37fe GSEventRun + 104
    30  UIKit                               0x0238a94b UIApplicationMain + 1225
    31  ShowRoomPrive                       0x0026dfd5 main + 181
    32  ShowRoomPrive                       0x00002ba5 start + 53
)
libc++abi.dylib: terminating with uncaught exception of type NSException

1 个答案:

答案 0 :(得分:0)

使用下面的代码我认为你没有添加代表,这可能对你有帮助..

ABPeoplePickerNavigationController *picker =

[[ABPeoplePickerNavigationController alloc] init];

picker.peoplePickerDelegate = self;

[self presentViewController:picker animated:YES completion:nil];

或通过这个网址,它会给你一步一步的教程如何使用它 http://yuvarajmanickam.wordpress.com/2012/09/19/get-contact-number-from-abpeoplepickernavigationcontroller-ios-apps/ 或者使用Apple文档显示有用的信息

https://developer.apple.com/library/ios/documentation/ContactData/Conceptual/AddressBookProgrammingGuideforiPhone/Chapters/QuickStart.html