国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 系統(tǒng) > iOS > 正文

iOS開發(fā) 多個cell在初始化時注意重用池

2019-11-09 19:06:36
字體:
供稿:網(wǎng)友
多個cell在

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

方法中一定要分開來,用if或者switch,每一次上滑下拉都會調(diào)用這個方法,所以init初始化前面也必須加上

if (cell0 == nil)

來判斷,不然會init多個cell

下面是一個實例

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{    if (indexPath.section == 0 && hadPublish) {        static NSString *cellIndentifier0 = @"headCell0";        HeadCurrent_View_Cell *cell0 = [tableView dequeueReusableCellWithIdentifier:cellIndentifier0];        if (cell0 == nil) {            cell0 = [[HeadCurrent_View_Cell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellIndentifier0];        }        。。。。        return cell0;    }    else if (indexPath.section == 0 &&!hadPublish){        static NSString *cellIndentifier1 = @"headCellDefault";        UITableViewCell *cell0 = [tableView dequeueReusableCellWithIdentifier:cellIndentifier1];        if (cell0 == nil) {            cell0 = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellIndentifier1];
            。。。。
        }                cell0.selected = NO;        cell0.selectionStyle = UITableViewCellSelectionStyleNone;        return cell0;    }        static NSString *cellIndentifier = @"passengerOrderCell";    PassengerOrderTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIndentifier];    if (cell == nil) {        cell = [[PassengerOrderTableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellIndentifier];    }    。。。。    return cell;}


發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 昌平区| 青岛市| 桓仁| 临清市| 临安市| 苗栗县| 万宁市| 凤凰县| 比如县| 杂多县| 永安市| 辽源市| 浙江省| 金寨县| 孝感市| 五家渠市| 徐州市| 利辛县| 庄河市| 禹州市| 社旗县| 霍州市| 三都| 沿河| 长汀县| 雅安市| 屯留县| 仁怀市| 萝北县| 菏泽市| 噶尔县| 娱乐| 肥乡县| 德安县| 松原市| 运城市| 布拖县| 喀喇| 伽师县| 阳谷县| 吴川市|