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

Sample code for show just one menu in tableview #427

Closed
Husseinhj opened this issue Jan 16, 2019 · 0 comments
Closed

Sample code for show just one menu in tableview #427

Husseinhj opened this issue Jan 16, 2019 · 0 comments

Comments

@Husseinhj
Copy link

Husseinhj commented Jan 16, 2019

If you want to just show a single swipe menu in TableView can try with my sample:

Create a property the keep last cell has shown the menu.

@interface MyViewController ()<UITableViewDelegate,UITableViewDataSource ,SWTableViewCellDelegate>

@property (nonatomic, strong) SWTableViewCell *lastSWCell;

@end

Then implement this code to hide the menu of the last cell has been shown.

-(void) swipeableTableViewCell:(SWTableViewCell *)cell scrollingToState:(SWCellState)state{
    if (state != kCellStateCenter) {
        if (self.lastSWCell) {
            [self.lastSWCell hideUtilityButtonsAnimated:YES];
        }
        self.lastSWCell = cell;
    }
}

If you want to hide the menu when user scrolled the TableView implement this:

- (void)scrollViewDidScroll:(UIScrollView *)scrollView{
    if (self.lastSWCell) {
        [self.lastSWCell hideUtilityButtonsAnimated:YES];
        self.lastSWCell = nil;
    }
}

SampleVideo

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

1 participant