仿iOS通訊錄頁面設計

2021-06-22 15:18:05 字數 839 閱讀 2414

先上圖,大家看看效果

原理:1、從資料中獲取的通訊錄資訊存入nsmutablearray中

2、將姓名進行拼音化處理,按順序排序,並將首字母相同的陣列以首字母為關鍵字存放到nsmutabledectionary中

排序方法用的是nssortdescriptor中的sortdecriptorwithkey:方法

3、利用uitableview中的方法進行實現。主要是實現這五個方法:

- (nsarray *)sectionindextitlesfortableview:(uitableview *)tableview;//繪製**右側索引

- (nsinteger)numberofsectionsintableview:(uitableview *)tableview;//指定有多少個分割槽

- (nsstring *)tableview:(uitableview *)tableview titleforheaderinsection:(nsinteger)section;//顯示列表分組頭名

- (nsinteger)tableview:(uitableview *)tableview numberofrowsinsection:(nsinteger)section;//確定每個分割槽有多少行

- (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath;//繪製cell

iOS 通訊錄排序

在很多時候需要處理分組資訊 和 資料排序 按時間 字母 排序,類似通訊錄 如下圖 做這個 我的思路是用字典 這裡按字母abcd排序 首先把中文轉換成拼音,擷取第乙個字母 然後插入字典 字母作為key 並根據key對應的value建立為陣列,第二次取出字典中所有的key 判斷新的key是否在所有key...

iOS 獲取通訊錄

獲取通訊錄資料放到模型陣列裡 第一步在呼叫改方法之前,需要先新建乙個模型用來存放獲取到的聯絡人資料,大概如下 property nonatomic,strong nsstring firstname property nonatomic,strong nsstring lastname proper...

IOS如何訪問通訊錄

讀取所有聯絡人 void readallpeoples dispatch semaphore wait sema,dispatch time forever dispatch release sema else 取得本地所有聯絡人記錄 if tmpaddressbook nil nsarray tm...