Search code examples
objective-cuitableviewios7overlap

Cell text overlaps the editingAccessory when try to delete a row in iOS7


When I compile my app in the new iOS7, I found a problem when entering in the edit mode of an UITableView.

When I press in the red minus button to delete a row of the table, this row indent to the left to let appear the 'Delete' button. However, when this button appears, the text of the cell overlaps the editingAccesory (this happens only when the text is longer than the length of the cell).

How can I remove the overlapping?

Edit: Images in the comments

Edit 2: Tis is the code of the creation of the table

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{  
        return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
        return [_tweetList count];
} 

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
        static NSString *CellIdentifier = @"SessionDetailCell";
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
        Tweet *tweet = [_tweetList objectAtIndex:indexPath.row];
        cell.textLabel.text = tweet.text;
        return cell;
 }

 - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
        if (editingStyle == UITableViewCellEditingStyleDelete) {
                [tableView beginUpdates];

                Tweet *deletedTweet = [_tweetList objectAtIndex:indexPath.row];
                [_selectedSession removeTweetsObject:deletedTweet];
                [deletedTweet deleteEntity];
                _tweetList = [Tweet findAllSortedBy:@"index" ascending:YES withPredicate:[NSPredicate predicateWithFormat:@"session == %@",_selectedSession]];
                [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];

                [tableView endUpdates];
        }
        [[NSManagedObjectContext defaultContext]saveToPersistentStoreWithCompletion:nil];
}

- (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath
{
        selectedPath = indexPath;
        [self performSegueWithIdentifier:@"EditTweet" sender:self];
}

Solution:

Finally, I put the accessoryButton in the default state, and I use the edit state only to delete the rows. It's the only solution I've found :(

Perhaps, the method "willTransitionToState" can help people to solve similar problems.


Solution

  • You can hide or remove editingAccesory in editing mode , so there is no overlapping there,

    set this, enter image description here

    Screenshot:

    enter image description here