Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/111.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/26.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/design-patterns/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 一个类中可以有两个单元标识符吗?_Ios_Objective C_Uitableview - Fatal编程技术网

Ios 一个类中可以有两个单元标识符吗?

Ios 一个类中可以有两个单元标识符吗?,ios,objective-c,uitableview,Ios,Objective C,Uitableview,我只是想知道有没有办法在一个TableViewController类中包含两个不同的单元标识符?这是我的第一个手机识别码 static NSString *CellIdentifier = @"TableCell"; TableCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath]; 我正在尝试创建另一个单元标识符,但是每当我创建时,就会出现一个错误,说我有

我只是想知道有没有办法在一个
TableViewController
类中包含两个不同的
单元标识符
?这是我的第一个手机识别码

static NSString *CellIdentifier = @"TableCell";
TableCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];

我正在尝试创建另一个
单元标识符
,但是每当我创建时,就会出现一个
错误
,说我有一个重复的代码,即使我更改了单元标识符的名称。任何帮助都会很好

是的!您可以在一个类中创建两个单元格标识符。但是不同的自定义单元格xib和不同的标识符

static NSString *CellIdentifier1 = @"CellID1";
    CustomCell1 *cell1 = [table dequeueReusableCellWithIdentifier:CellIdentifier1 forIndexPath:indexPath];

static NSString *CellIdentifier2 = @"CellID2";
    CustomCell2 *cell2 = [table dequeueReusableCellWithIdentifier:CellIdentifier2 forIndexPath:indexPath];

//While loading cell 

if(indexPath.row ==0)
{
// cell1 code
}
if(indexPath.row ==1)
{
// cell2 code
}

发布问题代码,因为如果需要,一个表视图中可以有几十个单元格标识符。不,我只是在尝试创建另一个单元格标识符时出错,我想知道是否有办法创建两个单元格标识符,而不会出现重复的代码错误。再次,发布问题代码。请不要发布代码图像。最好用实际代码更新您的问题。无论如何,您不能有两个
cellForRow:
方法,只有一个。使用基于
indepath
if
语句查看我对另一个问题的回答:单元格标识符的代码和对
dequeueReusableCell
的调用应该在
if
语句中,而不是在前面。