I have a UITableView showing cells under different sections. The cells within each section can be deleted. I.e., when the UITableView is in edit mode, the cells' styles are set to UITableViewCellEditingStyleDelete. When the user clicks the delete button within a cell with this style, the Delete confirmation button shows to the right as expected. Since updating to iOS version 8.1, the row's contents and the contents of the section header cells above it are skewed to the left.
In Delete Mode, before clicking on delete button on the left hand side
After clicking on delete button on the left hand side
This was working fine up until I updated to iOS version 8.1. Has anyone else run into this?
Edit: Relevant snippets of code
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return [[_store getGroceryAisles] itemCount];
}
- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath
{
if ([self isCellBeingEdited:indexPath])
{
return UITableViewCellEditingStyleNone;
}
else
{
return (_editIsDeleting) ? UITableViewCellEditingStyleDelete : UITableViewCellEditingStyleInsert ;
}
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
NSArray* aisles = [[[self store] getGroceryAisles] list];
HGGSGroceryAisle* aisle = [aisles objectAtIndex:section];
return [[aisle grocerySections ] count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString *cellIdentifier = @"GrocerySectionCell";
HGGSGrocerySection * grocerySection;
grocerySection = [self grocerySectionAt:indexPath inTableView:tableView];
if ([self isCellBeingEdited:indexPath])
{
if ([tableView isEditing])
cellIdentifier = EDIT_CELL_ID;
else
{
_ipBeingEdited = nil;
}
}
UITableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if ([cellIdentifier isEqualToString:EDIT_CELL_ID])
{
NSString* name = [grocerySection name];
// skipping other code to set up cell when editing cell....
_cellBeingEdited = cell;
}
else
{
[[cell textLabel] setText:[grocerySection name]];
}
return cell;
}
-(UITableViewCell*)tableView:(UITableView*)tableView viewForHeaderInSection:(NSInteger)section
{
NSString *cellIdentifier;
HGGSGroceryAisle* aisle;
if ((tableView == [self tableView]) && (section == 0))
{
cellIdentifier = (tableView.isEditing) ? @"EditngAislesConfigHeaderCell" : @"AislesConfigHeaderCell";
}
else
cellIdentifier = @"GrocerySectionHeaderCell";
UITableViewCell *cell= [[self tableView] dequeueReusableCellWithIdentifier:cellIdentifier];
UILabel *aisleLabel = (UILabel*)[cell viewWithTag:1] ;
NSString *aisleLabelText = [NSString stringWithFormat:@"Aisle %li",(long)[aisle number]];
aisle = [[_store getGroceryAisles] itemAt:section];
[aisleLabel setText:aisleLabelText];
[aisleLabel setAccessibilityLabel:aisleLabelText];
return cell;
}
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
{
if ((_ipBeingEdited) && (_ipBeingEdited.row == indexPath.row) && (_ipBeingEdited.section == indexPath.section))
return NO;
else
return YES;
}
- (BOOL)tableView:(UITableView *)tableView shouldIndentWhileEditingRowAtIndexPath:(NSIndexPath *)indexPath
{
return NO;
}
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
if (editingStyle == UITableViewCellEditingStyleDelete)
{
// Delete the row from the data source
[_store removeGrocerySection:[self grocerySectionAt:indexPath inTableView:tableView] fromAisle:[self aisleAt:indexPath inTableView:tableView]];
[tableView reloadData];
}
}