I have a UITableView inside UITableViewCell. The inner tableview is of size 5 with each cell contentview of different background color and is editable.I'm able to reorder the tableviewcells of inner tableview.
I have a custom backgroundview for outer UITableViewCell.
UIView *selectedBackgroundView = [[UIView alloc] init];
selectedBackgroundView.layer.borderColor = [[UIColor grayColor] CGColor];
selectedBackgroundView.layer.borderWidth = 1;
selectedBackgroundView.backgroundColor = [UIColor clearColor];
cell.selectedBackgroundView = selectedBackgroundView;
When I select the tableviewcell, the bg color of tableviewcells of inner tableview changes to white.
//CellForRow code of Parent TableView
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
TableViewCellCustom *cell = (TableViewCellCustom *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
[[NSBundle mainBundle] loadNibNamed:@"TableViewCellCustom" owner:self options:nil];
cell = _tableViewCellCustom;
UIView *selectedBackgroundView = [[UIView alloc] init];
selectedBackgroundView.layer.borderColor = [[UIColor grayColor] CGColor];
selectedBackgroundView.layer.borderWidth = 1;
selectedBackgroundView.backgroundColor = [UIColor clearColor];
cell.selectedBackgroundView = selectedBackgroundView;
}
CustomPosition *customPosition = [_filteredArray objectAtIndex:indexPath.row];
[cell setProductsArray: customPosition.productsArray];//Sets the products and reloads child tableview
return cell;
}
//CellForRow of Child Tableview
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
TableViewCellProduct *cell = (TableViewCellProduct *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
[[NSBundle mainBundle] loadNibNamed:@"TableViewCellProduct" owner:self options:nil];
cell = _tableViewCellProduct;
cell.viewProduct.transform = CGAffineTransformRotate(cell.viewProduct.transform, M_PI_2);
}
switch (indexPath.row) {
case 0:
cell.viewProduct.backgroundColor = [UIColor redColor];
break;
case 1:
cell.viewProduct.backgroundColor = [UIColor greenColor];
break;
case 2:
cell.viewProduct.backgroundColor = [UIColor blueColor];
break;
case 3:
cell.viewProduct.backgroundColor = [UIColor yellowColor];
break;
case 4:
cell.viewProduct.backgroundColor = [UIColor grayColor];
break;
default:
break;
}
Product *product = [_productsArray objectAtIndex:indexPath.row];
cell.lblProductName.text = product.name;
return cell;
}
Child tableview is rotated because i wanted horizontal tableview.
Anyone knows what is the solution for this?