日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

tableView的用法具体解释

發布時間:2025/3/17 编程问答 35 豆豆
生活随笔 收集整理的這篇文章主要介紹了 tableView的用法具体解释 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
1 tableView的類型
? 1.1 UITableViewStylePlain? 沒有區頭 不顯區頭 ? ? 向上滑動區頭不會移動到屏幕外面
’ 1.2 UITableViewStyleGrouped? 有區頭? ? ? ? ? 表滑動,區頭會移動
2 cell accessory ? cell的配件
//cell配件(accessory)
// 0 none 什么也沒有
// 1 DisclosureIndicator? 多了一個指向右側的button
// 2 DetailButton 具體信息button
? ? // 3 Checkmark 對勾
// 4 DetailDisclosureButton? 具體信息button + 指向右側的箭頭
? ? cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;


? ? 還能夠在設置huadong




3 設置cell 選中狀態
??//設置選擇類型 默覺得灰底
? ? cell.selectionStyle = UITableViewCellSelectionStyleDefault;

4 NSCopying 協議 作用是僅僅有實現此方法的類就能夠調用copy方法
系統的某些類是默認實現NSCopying協議,諸如NSSting,NSArray,NSDictionary等;
? ? ? 所以 之前的People的類的對象默認是不能調用copy方法,由于People沒有實現NSCopying協議中的copyWithZone方法.
? ? 暫時字符串的引用計數是 -1? NSString *str = @"laosun";
通過創建字符串的對象的方式 引用計數為1 能夠進行拷貝 引用計數加 1 效果等同于retain? ?
? NSString *str1 = [NSString stringWithFormat:@"laosun"];


? 4.1 淺拷貝 copy
? ? ? ? ? ? retain拷貝的時指針,對象僅僅有一個,結果使得對象的引用計數 + 1
?? 4.2 深拷貝? 真正意義上的拷貝,僅僅是要產生兩個對象,并且每一個對象的引用計數是1


5 //? 此屬性就能夠取代 設置區頭高度的 協議方法
_tableView.sectionHeaderHeight = 50;


6 創建tableView所必須的三個方法
? ? 6.1? //在tableView上有幾個區域
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
?6.2 //每一個區域有多上行
???? - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
?6.3? 每一行的cell
?? ? - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath




7 相關協議
7.1??區頭須要多個控件 則能夠先創建一個View,然后再view上加入控件,view和相關控件在例如以下的方法中創建
-(UIView*)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section;


?? 7.2? 設置cell的編輯風格
? ? - (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath;


?? ? 風格類型
?? ? 7.2.1 UITableViewCellEditingStyleDelete? ? ? 刪除
7.2.2 ? ? UITableViewCellEditingStyleInsert 插入
?? ? 7.2.3 UITableViewCellEditingStyleNone? ? ? ? 默認


??? 7.3 cell能否夠移動 返回的時一個BOOL值
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath


? ? 7.3.1 用來移動的三杠
?? ? - (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)sourceIndexPath toIndexPath:(NSIndexPath *)destinationIndexPath


??移動邏輯: 取>刪>加入


?? 7.4? 完畢編輯


? ? ? ? -(void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath;


刪除和插入所做的操作寫在這里 刪除邏輯:刪除對象 > 刪除行


8? 展開閉合邏輯:
通過一個bool值推斷(_falg[3]),假設是yes則返回對應數組的count,否則返回0 (在和行相關的方法中),刷新對應的行的數據


9? ? 表的編輯? 增 ,刪 ,移

轉載于:https://www.cnblogs.com/yutingliuyl/p/7354339.html

總結

以上是生活随笔為你收集整理的tableView的用法具体解释的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。