仿IOS通讯录效果,实现获取手机通讯录、字母排序显示、搜索联系人、拨打电话
生活随笔
收集整理的這篇文章主要介紹了
仿IOS通讯录效果,实现获取手机通讯录、字母排序显示、搜索联系人、拨打电话
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
1.使用UITableView,實現聯系人字母排序、點擊字母跳轉顯示聯系人組目錄;
2.使用UISearchController,實現聯系搜索,動態顯示符合查詢的聯系人;
3.點擊通訊錄列表項,顯示聯系人信息(使用自定義模式化窗口類似與UIAlertView,使用UIwindow實現),點擊撥號,可以直接撥打電話;
4.實現獲取手機通訊錄里面的聯系人信息;
詳情見資源:http://download.csdn.net/detail/u011622479/9505751
效果圖如下:
獲取聯系人:
? ? ? ? ? ?
搜索頁:
?? ? ? ? ? ? ? ? ? ?? ? ?
聯系人信息:
主要顯示頁面代碼:
// // ViewController.m // ContactionView // // Created by rong xiang on 16/4/26. // Copyright ? 2016年 hzz. All rights reserved. //#import "ViewController.h" #import <AddressBook/AddressBook.h> #import "MobileAddressBook.h" #import "ChineseString.h" #import "CustomAlertView.h" #import "MyButton.h"@interface ViewController (){NSMutableArray * listSection;NSMutableArray * addressBookTemp;NSMutableArray * listPhone;NSMutableArray *_searchContacts;//符合條件的搜索聯系人CustomAlertView * alertView;UITableView *tableViewAddress;UISearchBar * _searchBar;UISearchDisplayController *_searchDisplayController; }@end@implementation ViewController-(void) loadView{[super loadView];tableViewAddress = [[UITableView alloc] initWithFrame:CGRectMake(0, 20, self.view.frame.size.width, self.view.frame.size.height - 20)];[tableViewAddress setBackgroundColor:[UIColor colorWithRed:250.0f/255.0f green:250.0f/255.0f blue:250.0f/255.0f alpha:1.0]];[tableViewAddress setSeparatorStyle:UITableViewCellSeparatorStyleNone];[self.view addSubview:tableViewAddress];[self addSearchBar];}- (void)viewDidLoad {[super viewDidLoad];//初始化顯示對象addressBookTemp = [[NSMutableArray alloc] init];listSection = [[NSMutableArray alloc] init];listPhone =[[NSMutableArray alloc] init];NSMutableArray * listPhoneShow = [[NSMutableArray alloc] init];tableViewAddress.delegate = self;tableViewAddress.dataSource = self;//獲取通訊錄聯系人信息[self getAddressBook];//測試下的:初始化列表數據[self initData];//獲取通訊錄列表首字母,并排序listSection = [ChineseString IndexArray:addressBookTemp];//獲取通訊錄,并把通訊錄對象按照首字母進行分組排序listPhoneShow = [ChineseString LetterSortArray:addressBookTemp];//把對應的同一個首字母下聯系人對象按照首字母排序列表進行分組;NSInteger count = [listPhoneShow count];NSArray * array = nil;for(int i =0;i<count;i++){array =[listPhoneShow objectAtIndex:i];NSInteger arrCount = [array count];NSMutableArray * showArr = [[NSMutableArray alloc] init];for(int j =0;j< arrCount;j++){NSString *tempStr = [array objectAtIndex:j];for(MobileAddressBook * add in addressBookTemp){if([[add name] isEqualToString:tempStr]){add.firstName = [listSection objectAtIndex:i];[showArr addObject:add];break;}}}[listPhone addObject:showArr];}}-(void) dealloc{tableViewAddress.dataSource = nil;tableViewAddress.delegate = nil;}- (void)didReceiveMemoryWarning {[super didReceiveMemoryWarning];// Dispose of any resources that can be recreated. }#pragma mark 搜索形成新數據 -(void)searchDataWithKeyWord:(NSString *)keyWord{//_isSearching=YES;_searchContacts=[NSMutableArray array];int count = [listPhone count];int arrCount = 0;NSArray * arr = nil;MobileAddressBook * contact = nil;//過濾for(int i=0;i<count;i++){arr = [listPhone objectAtIndex:i];arrCount = arr.count;for(int j=0;j<arrCount;j++){contact = [arr objectAtIndex:j];if ([contact.firstName.uppercaseString containsString:keyWord.uppercaseString]||[contact.name.uppercaseString containsString:keyWord.uppercaseString]||[contact.tel containsString:keyWord]) {[_searchContacts addObject:contact];}}}// [listPhone enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { // NSArray * arr =obj; // [arr enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { // MobileAddressBook * contact = obj; // if ([contact.firstName.uppercaseString containsString:keyWord.uppercaseString]||[contact.name.uppercaseString containsString:keyWord.uppercaseString]||[contact.tel containsString:keyWord]) { // [_searchContacts addObject:contact]; // } // }]; // }]; }#pragma mark 添加搜索欄 -(void)addSearchBar{_searchBar=[[UISearchBar alloc]init];[_searchBar sizeToFit];//大小自適應容器_searchBar.placeholder=@"搜索聯系人";_searchBar.autocapitalizationType=UITextAutocapitalizationTypeNone;_searchBar.showsSearchResultsButton = YES;//添加搜索框到頁眉位置_searchBar.delegate=self;tableViewAddress.tableHeaderView=_searchBar;_searchDisplayController=[[UISearchDisplayController alloc]initWithSearchBar:_searchBar contentsController:self];_searchDisplayController.delegate=self;_searchDisplayController.searchResultsDataSource=self;_searchDisplayController.searchResultsDelegate=self;_searchDisplayController.searchResultsTitle=@"沒有符合的聯系人";[_searchDisplayController setActive:NO animated:YES];}// 選擇完成,跳轉回去 -(void) searchBarCancelButtonClicked:(UISearchBar *)searchBar{[tableViewAddress reloadData]; }-(void) searchBarResultsListButtonClicked:(UISearchBar *)searchBar{[tableViewAddress reloadData]; }#pragma 選擇/全選/確定/返回/獲取手機通訊錄 -(void) goBack {[self.navigationController popViewControllerAnimated:NO]; }#pragma --獲取手機通訊錄-(void) getAddressBook{//新建一個通訊錄類ABAddressBookRef addressBooks = nil;if ([[UIDevice currentDevice].systemVersion floatValue] >= 6.0){addressBooks = ABAddressBookCreateWithOptions(NULL, NULL);//獲取通訊錄權限dispatch_semaphore_t sema = dispatch_semaphore_create(0);ABAddressBookRequestAccessWithCompletion(addressBooks, ^(bool granted, CFErrorRef error){dispatch_semaphore_signal(sema);});dispatch_semaphore_wait(sema, DISPATCH_TIME_FOREVER);// dispatch_release(sema);}else{addressBooks = ABAddressBookCreate();}//獲取通訊錄中的所有人CFArrayRef allPeople = ABAddressBookCopyArrayOfAllPeople(addressBooks);//通訊錄中人數CFIndex nPeople = ABAddressBookGetPersonCount(addressBooks);//循環,獲取每個人的個人信息for (NSInteger i = 0; i < nPeople; i++){//新建一個addressBook model類MobileAddressBook *addressBook = [[MobileAddressBook alloc] init];//獲取個人ABRecordRef person = CFArrayGetValueAtIndex(allPeople, i);//獲取個人名字CFTypeRef abName = ABRecordCopyValue(person, kABPersonFirstNameProperty);CFTypeRef abLastName = ABRecordCopyValue(person, kABPersonLastNameProperty);CFStringRef abFullName = ABRecordCopyCompositeName(person);NSString *nameString = (__bridge NSString *)abName;NSString *lastNameString = (__bridge NSString *)abLastName;if ((__bridge id)abFullName != nil) {nameString = (__bridge NSString *)abFullName;} else {if ((__bridge id)abLastName != nil){nameString = [NSString stringWithFormat:@"%@ %@", nameString, lastNameString];}}addressBook.name = nameString;addressBook.recordID = (int)ABRecordGetRecordID(person);;ABPropertyID multiProperties[] = {kABPersonPhoneProperty,kABPersonEmailProperty};NSInteger multiPropertiesTotal = sizeof(multiProperties) / sizeof(ABPropertyID);for (NSInteger j = 0; j < multiPropertiesTotal; j++) {ABPropertyID property = multiProperties[j];ABMultiValueRef valuesRef = ABRecordCopyValue(person, property);NSInteger valuesCount = 0;if (valuesRef != nil) valuesCount = ABMultiValueGetCount(valuesRef);if (valuesCount == 0) {CFRelease(valuesRef);continue;}//獲取電話號碼和emailfor (NSInteger k = 0; k < valuesCount; k++) {CFTypeRef value = ABMultiValueCopyValueAtIndex(valuesRef, k);switch (j) {case 0: {// Phone numberaddressBook.tel = [(__bridge NSString*)value stringByReplacingOccurrencesOfString:@"-" withString:@""];addressBook.tel = [addressBook.tel stringByReplacingOccurrencesOfString:@" " withString:@""];addressBook.tel = [addressBook.tel stringByReplacingOccurrencesOfString:@"+86" withString:@""];break;}case 1: {// EmailaddressBook.email = (__bridge NSString*)value;break;}}CFRelease(value);}CFRelease(valuesRef);}//將個人信息添加到數組中,循環完成后addressBookTemp中包含所有聯系人的信息if(addressBook.tel.length != 11 ||addressBook.tel==nil||[addressBook.tel isEqual:@""]||[[addressBook.tel substringToIndex:3] isEqualToString:@"028"])continue;[addressBookTemp addObject:addressBook];if (abName) CFRelease(abName);if (abLastName) CFRelease(abLastName);if (abFullName) CFRelease(abFullName);} }-(void) initData{MobileAddressBook * mab= [[MobileAddressBook alloc] init];[mab setRecordID:1];[mab setSectionNumber:0];[mab setTel:@"15281008411"];[mab setEmail:@""];[mab setName:@"胡玉鉉"];[addressBookTemp addObject:mab];mab= [[MobileAddressBook alloc] init];[mab setRecordID:1];[mab setSectionNumber:0];[mab setTel:@"15281008411"];[mab setEmail:@""];[mab setName:@"hu鉉"];[addressBookTemp addObject:mab];mab= [[MobileAddressBook alloc] init];[mab setRecordID:2];[mab setSectionNumber:0];[mab setTel:@"15281008411"];[mab setEmail:@""];[mab setName:@"幸運星"];[addressBookTemp addObject:mab];mab= [[MobileAddressBook alloc] init];[mab setRecordID:1];[mab setSectionNumber:0];[mab setTel:@"15281008411"];[mab setEmail:@""];[mab setName:@"夏鉉"];[addressBookTemp addObject:mab];mab= [[MobileAddressBook alloc] init];[mab setRecordID:1];[mab setSectionNumber:0];[mab setTel:@"15281008411"];[mab setEmail:@""];[mab setName:@"胡玉鉉"];[addressBookTemp addObject:mab];mab= [[MobileAddressBook alloc] init];[mab setRecordID:2];[mab setSectionNumber:0];[mab setTel:@"15281008411"];[mab setEmail:@""];[mab setName:@"斐雨雪"];[addressBookTemp addObject:mab];mab= [[MobileAddressBook alloc] init];[mab setRecordID:2];[mab setSectionNumber:0];[mab setTel:@"15281008411"];[mab setEmail:@""];[mab setName:@"愛惜月"];[addressBookTemp addObject:mab];mab= [[MobileAddressBook alloc] init];[mab setRecordID:2];[mab setSectionNumber:0];[mab setTel:@"15281008411"];[mab setEmail:@""];[mab setName:@"希"];[addressBookTemp addObject:mab];mab= [[MobileAddressBook alloc] init];[mab setRecordID:1];[mab setSectionNumber:0];[mab setTel:@"15281008411"];[mab setEmail:@""];[mab setName:@"薛"];[addressBookTemp addObject:mab];mab= [[MobileAddressBook alloc] init];[mab setRecordID:1];[mab setSectionNumber:0];[mab setTel:@"15281008411"];[mab setEmail:@""];[mab setName:@"陳鉉"];[addressBookTemp addObject:mab];mab= [[MobileAddressBook alloc] init];[mab setRecordID:1];[mab setSectionNumber:0];[mab setTel:@"15281008411"];[mab setEmail:@""];[mab setName:@"陳玉"];[addressBookTemp addObject:mab];mab= [[MobileAddressBook alloc] init];[mab setRecordID:1];[mab setSectionNumber:0];[mab setTel:@"15281008411"];[mab setEmail:@""];[mab setName:@"陳雪月"];[addressBookTemp addObject:mab];mab= [[MobileAddressBook alloc] init];[mab setRecordID:2];[mab setSectionNumber:0];[mab setTel:@"15281008411"];[mab setEmail:@""];[mab setName:@"陳婷"];[addressBookTemp addObject:mab];mab= [[MobileAddressBook alloc] init];[mab setRecordID:2];[mab setSectionNumber:0];[mab setTel:@"15281008411"];[mab setEmail:@""];[mab setName:@"Wien 吃"];[addressBookTemp addObject:mab];mab= [[MobileAddressBook alloc] init];[mab setRecordID:1];[mab setSectionNumber:0];[mab setTel:@"15281008411"];[mab setEmail:@""];[mab setName:@"wx"];[addressBookTemp addObject:mab];mab= [[MobileAddressBook alloc] init];[mab setRecordID:1];[mab setSectionNumber:0];[mab setTel:@"15281008411"];[mab setEmail:@""];[mab setName:@"文娛x"];[addressBookTemp addObject:mab];mab= [[MobileAddressBook alloc] init];[mab setRecordID:2];[mab setSectionNumber:0];[mab setTel:@"15281008411"];[mab setEmail:@""];[mab setName:@"張運出"];[addressBookTemp addObject:mab];mab= [[MobileAddressBook alloc] init];[mab setRecordID:2];[mab setSectionNumber:0];[mab setTel:@"15281008411"];[mab setEmail:@""];[mab setName:@"#12443"];[addressBookTemp addObject:mab];}#pragma --list 視圖-(NSInteger) numberOfSectionsInTableView:(UITableView *)tableView {if (tableView==self.searchDisplayController.searchResultsTableView) {return 1;}return [listSection count]; }-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {//如果當前是UISearchDisplayController內部的tableView則使用搜索數據if (tableView==self.searchDisplayController.searchResultsTableView) {return _searchContacts.count;}return [[listPhone objectAtIndex:section] count]; }-(NSString *) tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section{if (tableView==self.searchDisplayController.searchResultsTableView) {return @"搜索結果";}NSString *title = [listSection objectAtIndex:section];return title; }-(NSArray *) sectionIndexTitlesForTableView:(UITableView *) tableView{if (tableView==self.searchDisplayController.searchResultsTableView) {return [[NSArray alloc] init];}return listSection; }-(CGFloat) tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{if(section ==0)return 35;return 30; }-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{return 50; }- (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {// 組圖標UIImageView * imgHeader = nil;// 聯系人名稱UILabel * lblName = nil;// 號碼UILabel * lblPhone = nil;UIView * border = nil;static NSString *CellIndentifier = @"phone";UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIndentifier];if(cell == nil){cell = [[UITableViewCell alloc] init];[cell setRestorationIdentifier:CellIndentifier];[cell setSelectionStyle:UITableViewCellSelectionStyleNone];[cell.contentView setBackgroundColor:tableViewAddress.backgroundColor];imgHeader = [[UIImageView alloc] initWithFrame:CGRectMake(5, (cell.contentView.frame.size.height-40)/2, 40, 40)];[imgHeader setImage:[UIImage imageNamed:@"head_default4.jpg"]];imgHeader.tag = 99;[cell.contentView addSubview:imgHeader];lblName = [[UILabel alloc] initWithFrame:CGRectMake(imgHeader.frame.origin.x + imgHeader.frame.size.width +10, 5, cell.contentView.frame.size.width -imgHeader.frame.origin.x - imgHeader.frame.size.width*2 - 15, 21)];[lblName setFont:[UIFont systemFontOfSize:14.0f]];lblName.tag = 97;[cell.contentView addSubview:lblName];lblPhone = [[UILabel alloc] initWithFrame:CGRectMake(imgHeader.frame.origin.x + imgHeader.frame.size.width +10, 22, cell.contentView.frame.size.width -imgHeader.frame.origin.x - imgHeader.frame.size.width*2 - 15, 21)];[lblPhone setFont:[UIFont systemFontOfSize:14.0f]];lblPhone.tag = 96;[cell.contentView addSubview:lblPhone];border =[[UIView alloc] initWithFrame:CGRectMake(10, cell.frame.size.height - 1, cell.frame.size.width-35, 1)];[border setBackgroundColor:[UIColor colorWithRed:200.0f/255.0f green:200.0f/255.0f blue:200.0f/255.0f alpha:1.0]];border.tag = 95;[cell.contentView addSubview:border];}else {imgHeader = (UIImageView *)[cell.contentView viewWithTag:99];lblName = (UILabel *)[cell.contentView viewWithTag:97];lblPhone =(UILabel *)[cell.contentView viewWithTag:96];border = (UIView*)[cell.contentView viewWithTag:95];}MobileAddressBook * address=nil;// 如果顯示通訊錄列表if(tableView!=self.searchDisplayController.searchResultsTableView){address = [[listPhone objectAtIndex:indexPath.section] objectAtIndex:indexPath.row];NSInteger arrayCount = [[listPhone objectAtIndex:indexPath.section] count];if(arrayCount<=1 || indexPath.row==arrayCount-1)[border setHidden:YES];else[border setHidden:NO];}else{//如果顯示搜索列表address = [_searchContacts objectAtIndex:indexPath.row];}[lblName setText:address.name];[lblPhone setText:address.tel];return cell;}-(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{//顯示聯系人詳情MobileAddressBook * mab = nil;BOOL isSearch = NO;if(tableView == _searchDisplayController.searchResultsTableView){mab = [_searchContacts objectAtIndex:indexPath.row];isSearch = YES;}else{mab = [[listPhone objectAtIndex:indexPath.section] objectAtIndex:indexPath.row];isSearch = NO;}//彈出框,顯示聯系人信息UIView * subView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 300, 100)];[subView setBackgroundColor:[UIColor whiteColor]];subView.center = CGPointMake((self.view.frame.size.width)/2, (self.view.frame.size.height-subView.frame.size.height)/2);//添加頭像UIImageView * imgView = [[UIImageView alloc] initWithFrame:CGRectMake(17, 8, 45, 45)];[imgView setImage:[UIImage imageNamed:@"headerimage"]];[subView addSubview:imgView];//添加姓名UILabel * lblName =[[UILabel alloc] initWithFrame:CGRectMake(68, 19, 100, 21)];[lblName setFont:[UIFont systemFontOfSize:15.0f]];[lblName setText:mab.name];[subView addSubview:lblName];//添加“電話”標題UILabel * lblTitle = [[UILabel alloc] initWithFrame:CGRectMake(20, 56, 68, 21)];[lblTitle setText:@"電話"];[lblTitle setFont:[UIFont systemFontOfSize:12.0f]];[lblTitle setTextColor:[UIColor grayColor]];[subView addSubview:lblTitle];//添加電話號碼顯示UILabel * lblPhoneNo = [[UILabel alloc] initWithFrame:CGRectMake(17, 72, 100, 21)];[lblPhoneNo setText:mab.tel];[lblPhoneNo setFont:[UIFont systemFontOfSize:14.0f]];[subView addSubview:lblPhoneNo];//添加按鈕MyButton * btn = [[MyButton alloc] initWithFrame:CGRectMake(170, 70, 52, 21)];[btn setTitle:@"撥號" forState:UIControlStateNormal];[btn setTitleColor:[UIColor blueColor] forState:UIControlStateNormal];[btn addTarget:self action:@selector(Call:) forControlEvents:UIControlEventTouchUpInside];NSMutableDictionary * dic = [[NSMutableDictionary alloc] init]; // [dic setValue:isSearch?@"YES":@"NO" forKey:@"isSearch"]; // [dic setValue:indexPath forKey:@"IndexPath"];[dic setValue:mab forKey:@"Object"];[btn setObjectDic:dic];[subView addSubview:btn];btn = [[MyButton alloc] initWithFrame:CGRectMake(240, 70, 52, 21)];[btn setTitle:@"取消" forState:UIControlStateNormal];[btn setTitleColor:[UIColor blueColor] forState:UIControlStateNormal];[btn addTarget:self action:@selector(Cancel:) forControlEvents:UIControlEventTouchUpInside];[subView addSubview:btn];if(alertView != nil){[alertView setHidden:NO];[alertView.subviews[0] removeFromSuperview];}elsealertView = [[CustomAlertView alloc] init];alertView.subView = subView;[alertView initView];[alertView show]; } //撥打電話 -(void) Call:(id) sender{MyButton * btn = sender;[alertView dismiss];[alertView setHidden:YES];MobileAddressBook * addressBook = nil;addressBook = [btn.ObjectDic objectForKey:@"Object"];// NSIndexPath * indexPath = nil; // BOOL isSearch = NO; // NSMutableDictionary * dic = [btn ObjectDic]; // //獲取聯系人對象 // isSearch = [[dic objectForKey:@"isSearch"] isEqualToString:@"YES"]; // indexPath = [dic objectForKey:@"IndexPath"]; // // if(isSearch){ // addressBook = [_searchContacts objectAtIndex:indexPath.row]; // }else // addressBook = [[listPhone objectAtIndex:indexPath.section] objectAtIndex:indexPath.row];NSMutableString * str=[[NSMutableString alloc] initWithFormat:@"tel:%@", addressBook.tel];[[UIApplication sharedApplication] openURL:[NSURL URLWithString:str]]; }-(void) Cancel:(id) sender{[alertView dismiss];[alertView setHidden:YES]; }#pragma mark - UISearchDisplayController代理方法 -(BOOL)searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchString:(NSString *)searchString{[self searchDataWithKeyWord:searchString];return YES; }#pragma mark 重寫狀態樣式方法 -(UIStatusBarStyle)preferredStatusBarStyle{return UIStatusBarStyleLightContent; }#pragma mark 選中之前 -(NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath{[_searchBar resignFirstResponder];//退出鍵盤return indexPath; }@end自定義alertview代碼: // // CustomAlertView.h // ContactionView // // Created by rong xiang on 16/4/28. // Copyright ? 2016年 hzz. All rights reserved. //#import <UIKit/UIKit.h>@interface CustomAlertView : UIWindow @property (nonatomic,retain) UIView * subView;// 顯示 -(void) show; //消失 -(void) dismiss; -(void) initView;@end
操作文件: // // CustomAlertView.m // ContactionView // // Created by rong xiang on 16/4/28. // Copyright ? 2016年 hzz. All rights reserved. //#import "CustomAlertView.h"@implementation CustomAlertView @synthesize subView;-(id) initWithFrame:(CGRect)frame{self = [super initWithFrame:frame];if(self){self.windowLevel = UIWindowLevelAlert;//這里,不能設置UIWindow的alpha屬性,會影響里面的子view的透明度,這里可以用透明圖片來設置背影半透明self.backgroundColor = [UIColor colorWithPatternImage:[UIImageimageNamed:@"transparent"]];}// if(subView==nil){ // subView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 200, 80)]; // subView.backgroundColor = [UIColor lightGrayColor]; // subView.center = CGPointMake(160, 240); // } // [self addSubview:subView];return self; }-(void) initView{[self addSubview:subView];self.backgroundColor = [UIColor colorWithPatternImage:[UIImageimageNamed:@"transparent"]]; }-(void)show{[self makeKeyAndVisible]; }-(void) dismiss{[self resignKeyWindow]; }//點擊消失 -(void) touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{ // [self dismiss]; }-(void) touchesMoved:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{}-(void) touchesEnded:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{}@end
聯系人對象: // // MobileAddressBook.h // ContactionView // // Created by rong xiang on 16/4/26. // Copyright ? 2016年 hzz. All rights reserved. //#import <Foundation/Foundation.h>@interface MobileAddressBook : NSObject@property NSInteger sectionNumber; @property NSInteger recordID; @property (nonatomic, retain) NSString *name; @property (nonatomic,retain) NSString * firstName; @property (nonatomic, retain) NSString *email; @property (nonatomic, retain) NSString *tel; @end
操作文件 // // MobileAddressBook.m // ContactionView // // Created by rong xiang on 16/4/26. // Copyright ? 2016年 hzz. All rights reserved. //#import "MobileAddressBook.h"@implementation MobileAddressBook @synthesize recordID,sectionNumber,name,tel,email,firstName; @end
總結
以上是生活随笔為你收集整理的仿IOS通讯录效果,实现获取手机通讯录、字母排序显示、搜索联系人、拨打电话的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 苹果计算机磁盘格式,苹果电脑如何完全写入
- 下一篇: Jenkins安装(Maven安装)(4