Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ionic-framework/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios UITableView设计在滚动后立即不起作用_Ios_Objective C_Uitableview_Custom Cell - Fatal编程技术网

Ios UITableView设计在滚动后立即不起作用

Ios UITableView设计在滚动后立即不起作用,ios,objective-c,uitableview,custom-cell,Ios,Objective C,Uitableview,Custom Cell,我在我的应用程序中使用了UITableView,并使用了自定义单元格,当查看午餐时效果很好,但当滚动表格并再次设置时,它就像丑陋一样,就像图像一样。 }问题是您对单元格使用了相同的重用标识符。请分享您的cellforrowatinexpath方法,但我确信您在那里有一些类似“ID”的字符串。您有两种不同配置的单元格类型,因此也应该使用不同的标识符。例如,第一类单元格的“ID1”,以及其他单元格的“ID2” This simple example should fix the problem

我在我的应用程序中使用了UITableView,并使用了自定义单元格,当查看午餐时效果很好,但当滚动表格并再次设置时,它就像丑陋一样,就像图像一样。


}

问题是您对单元格使用了相同的
重用标识符。请分享您的
cellforrowatinexpath
方法,但我确信您在那里有一些类似
“ID”
的字符串。您有两种不同配置的单元格类型,因此也应该使用不同的标识符。例如,第一类单元格的
“ID1”
,以及其他单元格的
“ID2”

This simple example should fix the problem

NSString *identifier = nil;
NSInteger row = indexPath.row;
if ((row >= 5 && row <= 10) || row == 16) {
    identifier = @"CELLID1";
}
else {
    identifier = @"CELLID2";
}


DetailsTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier forIndexPath:indexPath];
....

问题是您对单元格使用了相同的
reuseIdentifier
。请分享您的
cellforrowatinexpath
方法,但我确信您在那里有一些类似
“ID”
的字符串。您有两种不同配置的单元格类型,因此也应该使用不同的标识符。例如,第一类单元格的
“ID1”
,以及其他单元格的
“ID2”

This simple example should fix the problem

NSString *identifier = nil;
NSInteger row = indexPath.row;
if ((row >= 5 && row <= 10) || row == 16) {
    identifier = @"CELLID1";
}
else {
    identifier = @"CELLID2";
}


DetailsTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier forIndexPath:indexPath];
....

您需要检查单元格,因为它们正在被重用

您的代码结构有点难以修改,有时切换情况会更好。在返回单元格之前,可以在底部添加以下内容:

switch(indexPath.row){
    case 5:
    case 6:
    case 7:
    case 8:
    case 9:
    case 10:
    case 16:
        cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator;
        break;
    default:
        cell.accessoryType = UITableViewCellAccessoryNone;
        break;
}
return cell;

您需要检查单元格,因为它们正在被重用

您的代码结构有点难以修改,有时切换情况会更好。在返回单元格之前,可以在底部添加以下内容:

switch(indexPath.row){
    case 5:
    case 6:
    case 7:
    case 8:
    case 9:
    case 10:
    case 16:
        cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator;
        break;
    default:
        cell.accessoryType = UITableViewCellAccessoryNone;
        break;
}
return cell;


任何UITableView函数?是否使用NSLayoutConstraint?看起来您在-(CGFloat)tableView:(UITableView*)tableView heightForRowAtIndexPath:(NSIndexPath*)InExpath返回了错误的单元格高度我不使用此函数,我使用了UITableView默认的heightcellatindexpath@AhmedAny UITableView函数?是否使用NSLayoutConstraint?在-(CGFloat)tableView:(UITableView*)tableView heightForRowAtIndexPath:(NSIndexPath*)InExpath中返回了错误的单元格高度我不使用此函数,我使用了UITableView默认的heightcellatindexpath@AhmedI与您共享了我的代码,但当您重新使用滚动单元格时,我在表格中使用了一个单元格。你应该多读一些。我会用Mint编写解决方案非常感谢您的关心,但它不起作用,因为我在Storyboard中给出了单元格名称。我与您共享了我的代码,但当您重新使用滚动单元格时,我在表格中使用了一个单元格。你应该多读一些。我将在Mint中编写解决方案非常感谢您的关心,但它不起作用,因为我在故事板中给出了单元格名称它的作用是删除附件披露指示器,但当滚动文本字段背景设置为灰色(如country and city cell)时,我建议2创建2个不同的uitableview自定义单元格。或者移动标签下方的文本字段以使内容保持一致,或者扩展我的示例以调整其他内容我修改了您的代码,并且正确切换(indexPath.row){案例5:案例6:案例7:案例8:案例9:案例10:案例16:cell.accessoryType=UITableViewCellAccessoryExtField.enabled=否;中断;默认值:cell.accessoryType=UITableViewCellAccessoryNone;cell.SellPropertyExtField.enabled=是;中断;}return cell;@meda thanks可用于删除附件discoverage indicator,但当滚动文本字段背景设置为灰色(如country and city cell)时,我建议2创建2个不同的uitableview自定义单元格。或者将文本字段移到标签下方以使内容一致,或者扩展我的示例以调整其他内容fy您的代码,并且它正确运行(indexPath.row){案例5:案例6:案例7:案例8:案例9:案例10:案例16:cell.accessoryType=UITableViewCellAccessoryExtField.enabled=否;中断;默认值:cell.accessoryType=UITableViewCellAccessoryNone;cell.SellPropertyExtField.enabled=是;中断;}返回手机;@meda谢谢