Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/97.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_Xcode_Uitableview_Uistoryboard - Fatal编程技术网

Ios UITableView:如何仅实现与其他行不同的一行

Ios UITableView:如何仅实现与其他行不同的一行,ios,xcode,uitableview,uistoryboard,Ios,Xcode,Uitableview,Uistoryboard,在故事板(Xcode 6)中,我希望设计一个这样的视图 这些行是动态的,因为内容是从web服务获取的。如何实现此视图 我已经尝试了一个图像视图(上面的图像带有用户名和图片)和下面的表格视图,但是当我滚动表格时,显然只滚动表格 链接中的图像是uitableview,只有第一行与另一行不同?如何只实现一行与另一行不同 感谢该视图可以是一个与表格一起滚动的tableHeaderView,也可以是一个单元格。您可以在表视图中创建任意数量的原型单元,并为它们提供不同的重用标识符。在cellForRowA

在故事板(Xcode 6)中,我希望设计一个这样的视图

这些行是动态的,因为内容是从web服务获取的。如何实现此视图

我已经尝试了一个图像视图(上面的图像带有用户名和图片)和下面的表格视图,但是当我滚动表格时,显然只滚动表格

链接中的图像是uitableview,只有第一行与另一行不同?如何只实现一行与另一行不同


感谢

该视图可以是一个与表格一起滚动的
tableHeaderView
,也可以是一个单元格。您可以在表视图中创建任意数量的原型单元,并为它们提供不同的重用标识符。在cellForRowATIndexPath中,放入if else子句,并根据indexPath.row将所需的任何单元格出列。

该视图可以是一个随表滚动的
tableHeaderView
,也可以是一个单元格。您可以在表视图中创建任意数量的原型单元,并为它们提供不同的重用标识符。在cellForRowATIndexPath中,放入if else子句,并根据indexPath.row将所需的任何单元格出列。

该视图可以是一个随表滚动的
tableHeaderView
,也可以是一个单元格。您可以在表视图中创建任意数量的原型单元,并为它们提供不同的重用标识符。在cellForRowATIndexPath中,放入if else子句,并根据indexPath.row将所需的任何单元格出列。

该视图可以是一个随表滚动的
tableHeaderView
,也可以是一个单元格。您可以在表视图中创建任意数量的原型单元,并为它们提供不同的重用标识符。在cellForRowATIndexPath中,放入if else子句,并根据indexPath.row将所需的任何单元格出列。

使用两个自定义单元格提供不同的标识符。一个用于第一行,另一个用于n-1单元格

并将cellForRowATIndexPath加载为

在此之前,请先使用一个临时数组

NSArray *arr=[[NSArra alloc]initWithObjects:@"FirstIdentifer",@"SecondIdientfier"];

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
 NSString *CellIdentifier = [self.menuItems objectAtIndex:indexPath.row];

    if ([CellIdentifier isEqualToString:@"FirstIdentifer"]) {
        Mycell *cell = (Mycell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];

        NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"TempCell" owner:self options:nil];
        cell = [nib objectAtIndex:0];
//do your stuff

        return  cell;

    }

    else
{
    static NSString *simpleTableIdentifier = @"SecondIdientfier";

    cell1 = (Mycell *)[tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];

    NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"Mycell" owner:self options:nil];
    cell1 = [nib objectAtIndex:0];
    //do your stuff


 return cell1;
}
}

假设两个自定义单元格提供不同的标识符。一个仅用于第一行,另一个用于n-1单元格

并将cellForRowATIndexPath加载为

在此之前,请先使用一个临时数组

NSArray *arr=[[NSArra alloc]initWithObjects:@"FirstIdentifer",@"SecondIdientfier"];

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
 NSString *CellIdentifier = [self.menuItems objectAtIndex:indexPath.row];

    if ([CellIdentifier isEqualToString:@"FirstIdentifer"]) {
        Mycell *cell = (Mycell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];

        NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"TempCell" owner:self options:nil];
        cell = [nib objectAtIndex:0];
//do your stuff

        return  cell;

    }

    else
{
    static NSString *simpleTableIdentifier = @"SecondIdientfier";

    cell1 = (Mycell *)[tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];

    NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"Mycell" owner:self options:nil];
    cell1 = [nib objectAtIndex:0];
    //do your stuff


 return cell1;
}
}

假设两个自定义单元格提供不同的标识符。一个仅用于第一行,另一个用于n-1单元格

并将cellForRowATIndexPath加载为

在此之前,请先使用一个临时数组

NSArray *arr=[[NSArra alloc]initWithObjects:@"FirstIdentifer",@"SecondIdientfier"];

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
 NSString *CellIdentifier = [self.menuItems objectAtIndex:indexPath.row];

    if ([CellIdentifier isEqualToString:@"FirstIdentifer"]) {
        Mycell *cell = (Mycell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];

        NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"TempCell" owner:self options:nil];
        cell = [nib objectAtIndex:0];
//do your stuff

        return  cell;

    }

    else
{
    static NSString *simpleTableIdentifier = @"SecondIdientfier";

    cell1 = (Mycell *)[tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];

    NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"Mycell" owner:self options:nil];
    cell1 = [nib objectAtIndex:0];
    //do your stuff


 return cell1;
}
}

假设两个自定义单元格提供不同的标识符。一个仅用于第一行,另一个用于n-1单元格

并将cellForRowATIndexPath加载为

在此之前,请先使用一个临时数组

NSArray *arr=[[NSArra alloc]initWithObjects:@"FirstIdentifer",@"SecondIdientfier"];

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
 NSString *CellIdentifier = [self.menuItems objectAtIndex:indexPath.row];

    if ([CellIdentifier isEqualToString:@"FirstIdentifer"]) {
        Mycell *cell = (Mycell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];

        NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"TempCell" owner:self options:nil];
        cell = [nib objectAtIndex:0];
//do your stuff

        return  cell;

    }

    else
{
    static NSString *simpleTableIdentifier = @"SecondIdientfier";

    cell1 = (Mycell *)[tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];

    NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"Mycell" owner:self options:nil];
    cell1 = [nib objectAtIndex:0];
    //do your stuff


 return cell1;
}
}