- (void)viewDidLoad {
[super viewDidLoad];
// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
UIBarButtonItem *btn = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"2.png"] style:UIBarButtonItemStyleBordered target:self action:nil];
self.navigationItem.rightBarButtonItem = btn;
self.navigationItem.title = @"Contacts";
sBar = [[UISearchBar alloc]initWithFrame:CGRectMake(0,0,320,30)];
sBar.delegate = self;
[self.view addSubview:sBar];
sBar.placeholder=@"Search";
searchedData = [[NSMutableArray alloc]init];
tableData = [[NSMutableArray alloc]init];
[tableData addObjectsFromArray:dataSource];
}
答案 0 :(得分:1)
Apple的iOS文档中的以下快速入门指南可以帮助您开始使用它。
Address Book Programming Guide for iPhone - QuickStart
它向您展示了如何导入AddressBookUI/AddressBookUI.h
标题并打开原生人选择器,以及收听某个人的时间。
答案 1 :(得分:0)
您需要实现以下表委托方法,以实际让您的表显示数据。
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
您可以在UITableView
here
答案 2 :(得分:0)
ABPerson
函数[ABAddressBookCopyArrayOfAllPeople]将在这里工作。
ABAddressBookRef addressBook = ABAddressBookCreate( );
CFArrayRef allPeople = ABAddressBookCopyArrayOfAllPeople( addressBook );
CFIndex nPeople = ABAddressBookGetPersonCount( addressBook );
for ( int i = 0; i < nPeople; i++ )
{
ABRecordRef ref = CFArrayGetValueAtIndex( allPeople, i );
...
}
获取npeople数组后,您可以在tableView中显示它或执行您想要实现的任何内容。