在Objective-C中创建iPhone联系人
问题描述:
我正尝试在内部通讯簿中创建联系人。我的代码如下:在Objective-C中创建iPhone联系人
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#import <AddressBook/AddressBook.h>
#import <AddressBookUI/AddressBookUI.h>
....
@interface CreateNewAccountPage : UIViewController <UIScrollViewDelegate,
UITextViewDelegate, MainMenuDelegate, ABNewPersonViewControllerDelegate> {
....
}
- (IBAction)goToContactCreation;
...
@end
在CreateNewAccountPage.m文件:
#import "CreateNewAccountPage.h"
@implementation CreateNewAccountPage
-(void)showNewPersonViewController
{
ABNewPersonViewController *picker = [[ABNewPersonViewController alloc] init];
picker.newPersonViewDelegate = self;
UINavigationController *navigation = [[UINavigationController alloc] initWithRootViewController:picker];
[self presentModalViewController:navigation animated:YES];
[picker release];
[navigation release];
}
-(IBAction)goToContactCreation {
[self showNewPersonViewController];
}
- (void)newPersonViewController:(ABNewPersonViewController *)newPersonViewController didCompleteWithNewPerson:(ABRecordRef)person
{
[self dismissModalViewControllerAnimated:YES];
}
...
@end
,我得到的错误是:
在CreateNewAccountPage.h文件“_OBJC_CLASS _ $ _ ABNewPersonViewController”,引用自: 在CreateNewAccountPage.o中的objc-class-ref-to-ABNewPersonViewController ld:sy MBOL(S)没有发现 collect2:LD返回1退出状态
如果我行注释掉:
ABNewPersonViewController *picker = [[ABNewPersonViewController alloc] init];
picker.newPersonViewDelegate = self;
...
[picker release];
我不再收到错误。我只是想要创建一个联系人。它不需要访问联系人列表。我只想要一个按钮来创建联系人。
非常感谢!
答
将AddressBook.framework,AddressBookUI.framework框架添加到您的项目中。
非常感谢! – Peter 2011-04-10 02:38:00