-(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;}
新聞熱點
疑難解答
圖片精選