Ios 在UITableView中随机添加自定义单元格

Ios 在UITableView中随机添加自定义单元格,ios,objective-c,uitableview,nsarray,Ios,Objective C,Uitableview,Nsarray,我有一个UITableView,其中填充了NSArray。数组在我的表中按字母顺序排列,标题按字母顺序排列 我在表格中每10行随机添加一个自定义单元格 我遇到的问题是,自定义单元格是在实际数据上分层的,因此它没有插入到数组中 我怎样才能解决这个问题 下面是插入自定义单元格的步骤: - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

我有一个
UITableView
,其中填充了
NSArray
。数组在我的表中按字母顺序排列,标题按字母顺序排列

我在表格中每10行随机添加一个自定义单元格

我遇到的问题是,自定义单元格是在实际数据上分层的,因此它没有插入到数组中

我怎样才能解决这个问题

下面是插入自定义单元格的步骤:

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

    if (indexPath.row % 10 == 10-1) {
        CustomAdCell *cell = (CustomAdCell *)[tableView dequeueReusableCellWithIdentifier:@"AdCell"];
        if (cell == nil)
        {
            NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"CustomAdCell" owner:self options:nil];
            cell = [nib objectAtIndex:0];
        }
        return cell;
    }
    else {

        static NSString *cellIdentifier = @"cellIdentifier";
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];

        // Configure the cell...
        if (!cell) {
            cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
            cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
        }

        NSString *key = [[[self indexedMembers] allKeys] sortedArrayUsingSelector:@selector(localizedCaseInsensitiveCompare:)][indexPath.section];

        self.indexedMembersArray = ((NSMutableArray *)[self indexedMembers][key]);

        MemberInfo *currentMember = self.indexedMembersArray[indexPath.row];

        cell.textLabel.text = [NSString stringWithFormat:@"%@ %@", currentMember.firstName, currentMember.lastName];

        return cell;
}

你找到解决办法了吗?你是怎么解决的?你找到解决办法了吗?你是怎么解决的?