UITableView에 연락처 이름 목록을 표시하는 iOS 앱이 있으며 셀을 탭하면 연락처가 ABPersonViewController
으로 표시됩니다. 이 프로젝트는 ARC를 사용합니다. 즉, ABPersonViewController
내 ABPersonViewControllerDelegate
이 (구현하는 방법을 보여줍니다ABPersonViewControllerDelegate를 사용할 때 EXC_BAD_ACCESS
(lldb) bt
* thread #1: tid = 0x2403, 0x39ee15b0 libobjc.A.dylib`objc_msgSend + 16, stop reason = EXC_BAD_ACCESS (code=1, address=0x8)
frame #0: 0x39ee15b0 libobjc.A.dylib`objc_msgSend + 16
frame #1: 0x319eb880 AddressBookUI`-[ABPersonViewControllerHelper notifyScrollViewDidLoad] + 64
가 UITableViewDelegate
방법 (아래 링크 전체 프로젝트)입니다 : 내가 ABPersonViewControllerDelegate
객체를 연결하는 경우, 응용 프로그램은 즉시 사람보기를 보여주는 후 AddressBookUI 프레임 워크에 EXC_BAD_ACCESS 안타) BEVPVDelegate
로는, 생성 관련 및 제시 :
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
ABPersonViewController *pvc = [[ABPersonViewController alloc] init];
BEVPVDelegate *pvDelegate = [[BEVPVDelegate alloc] init];
pvc.displayedPerson = (__bridge ABRecordRef)[self.contents objectAtIndex:[indexPath row]];
pvc.personViewDelegate = pvDelegate; // comment out this line to prevent the crash
[self.navigationController pushViewController:pvc animated:YES];
}
간단히 ABPersonViewController
인스턴스에서 personViewDelegate 속성을 설정 예외를 제거 라인을 주석,하지만 난 일이 필요 대리자 개체입니다. 여기
//
// BEVPVDelegate.m
// ABCrash
//
#import "BEVPVDelegate.h"
@implementation BEVPVDelegate
- (BOOL)personViewController:(ABPersonViewController *)personViewController shouldPerformDefaultActionForPerson:(ABRecordRef)person property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifier
{
NSLog(@"called");
return YES;
}
@end
문제 보여주는 베어 본 프로젝트의 : ABCrash.zip on Dropbox
내 코드에 문제가
이 BEVPVDelegate.m의 전체입니까? ABPersonViewControllerDelegate
을 사용할 수있는 해결 방법이 있습니까?
편집 : 방금 Instruments에서 프로젝트를 실행했고 personViewDelegate가 출시되었습니다. 내 UIViewController personViewDelegate 유지 된 속성을 만드는 경우 응용 프로그램이 충돌하지 않습니다.
personViewDelegate는 Apple에서 정의한 ABPersonViewController의 속성이므로 weak에서 strong으로 변경할 수 없습니다. 그러나 ABPersonViewController를 하위 클래스로 만들고 ABPersonViewControllerDelegate를 준수하도록 만들고'self.personViewDelegate = self; '를 추가하고 하위 클래스에 대리자 메서드를 구현했습니다. 그것으로 해결됩니다. – bneely