UITableView加载几种不同的cell
類似上面的圖片,一個滾動視圖上頜很多個模塊,以前用scrollview感覺不是很方便,想了下,其實(shí)可以用collectionview或者tableview的
UITableView舉例
其實(shí)就是一個 tableview加載幾個不同的cell,可以根據(jù)唯一標(biāo)示來判定
注冊:
? ? [_tableveiw?registerClass:[CustomCell?class]?forCellReuseIdentifier:@"cellID"];
? ??[_tableveiw?registerClass:[CustomCell1?class]?forCellReuseIdentifier:@"cellID1"];
? ??[_tableveiw?registerClass:[CustomCell2?class]?forCellReuseIdentifier:@"cellID2"];
加載
? ? UITableViewCell?*cell =?nil;
? ??if?(indexPath.section?==?0) {
? ? ? ??cell = [tableView?dequeueReusableCellWithIdentifier:@"cellID"];
? ? ? ??CustomCell?*newcell = (CustomCell?*)cell;
? ? ? ??newcell.label.text?=?@"00000";
?? ? ? ?
? ??}else?if?(indexPath.section?==?1){
? ? ? ??cell = [tableView?dequeueReusableCellWithIdentifier:@"cellID1"];
? ??}else?{
? ? ? ??cell = [tableView?dequeueReusableCellWithIdentifier:@"cellID2"];
? ??}
?? ?
? ??return?cell;?
?
轉(zhuǎn)載于:https://www.cnblogs.com/hxwj/p/4892704.html
創(chuàng)作挑戰(zhàn)賽新人創(chuàng)作獎勵來咯,堅(jiān)持創(chuàng)作打卡瓜分現(xiàn)金大獎總結(jié)
以上是生活随笔為你收集整理的UITableView加载几种不同的cell的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: unity脚本运行顺序具体的解释
- 下一篇: webapp 中为span元素赋值