简体   繁体   中英

Swipe-able Button Action

I am working on an app which is for a music app. And the main idea is to make the app look like something new. I have a Table and the Table has it's own cell. I created Swipeable method for the cell so when the user swipe to right it should show the DOWNLOAD Button and when the user swipes to left it should show the PLAY Button. Can anyone help in the regard of giving some specific action to those buttons? I can add Alerts or Views but I don't know how to add Actions specifically for the PLAY/PAUSE button?

This below code I am using?

- (void)swipeableTableViewCell:(SWTableViewCell *)cell didTriggerRightUtilityButtonWithIndex:(NSInteger)index {
    switch (index) {
        case 0:
        {
            /
            UIActionSheet  ----
            break;
- (void)swipeableTableViewCell:(SWTableViewCell *)cell didTriggerLeftUtilityButtonWithIndex:(NSInteger)index {

    switch (index) {
        case 0:
        {
            UIAlertView  --
            break;
        }

==== UPDATE ====

I want to create an APP for Music Player, so the question is if i have a cell usually prototype with Dynamic or Static Cells. and those cells are swipeable to left and right.

Now when i want to swipe it to the right the button should show Download and if it Swipe to the left the Button should show Play/Pause and after pressing the Button the song streaming should started.

Let me know please if that is clear.

Assuming your question is "How can I centralize all IBActions in a single location, you can use the UITableViewCell passed as a parameter to figure out what it the indexPath of the sender:

- (void)swipeableTableViewCell:(SWTableViewCell *)cell didTriggerRightUtilityButtonWithIndex:(NSInteger)index {
    // Step 1, figure out which UITableViewCell
    NSIndexPath *indexPath = [self.tableView indexPathForCell:(UITableViewCell *)
                              [[sender superview] superview]];

    // Step 2, dispatch using the button index
    switch (index) ...

    // At this time, you have bothe the index of the button and the index of the cell
    // You can take action for all UITableViewCells in this single location

}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM