Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Right button is clipped if UITableView has section index titles #8

Closed
subhashdaga opened this issue Sep 8, 2014 · 3 comments
Closed

Comments

@subhashdaga
Copy link

Right most button is clipped if you override the following UITableViewDataSource delegate -

  • (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView;

Any suggestions how it can be fixed? Thanks!

MortimerGoro pushed a commit that referenced this issue Sep 25, 2014
…dex titles. I have added an optional offset to change the swipe buttons position. Relative to the cell border position. Default value: 0. For example it can be used to avoid cropped buttons when sectionIndexTitlesForTableView is used in the UITableView
@MortimerGoro
Copy link
Owner

Hi subhashdaga,

I can't find a clean way to autodetect and automatically fix this issue but I have implemented a more generic feature that can be used to fix it. I have added a offset property to the swipeSettings class. Default value is 0, but if you set a value that is equal to the indexes view width it's done. I have tested it in the transitions demo project and it works ok with any transition.

@mmahkamov
Copy link

Faced the same issue. Took me some time to find about the offset property.

The offset property can be used like this to solve the issue with the section index titles:

- (NSArray *)swipeTableCell:(MGSwipeTableCell *)cell swipeButtonsForDirection:(MGSwipeDirection)direction swipeSettings:(MGSwipeSettings *)swipeSettings expansionSettings:(MGSwipeExpansionSettings *)expansionSettings {
    if (direction == MGSwipeDirectionRightToLeft) {
        // adjust the offset to the content width to account for the section index
        CGFloat offset = cell.frame.size.width - cell.contentView.frame.size.width;
        swipeSettings.offset = offset;

       ....
   }

   ...
}

There's no API to get the width of the section title index in iOS. However, the contentView of UITableViewCell is adjusted automatically not to overlap with the section title index. So you get the difference between the cell width and cell content width, then set it as the offset.

@ajbyrne
Copy link

ajbyrne commented Jul 29, 2020

Thanks. This works nicely.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants