简体   繁体   English

可滑动按钮动作

[英]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. 我为该单元格创建了Swipeable方法,因此,当用户向右滑动时,应显示“下载”按钮;当用户向左滑动时,应显示“播放”按钮。 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. 我想为Music Player创建一个APP,所以问题是我是否具有通常带有动态或静态单元格的单元原型。 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: 假设您的问题是“如何将所有IBAction集中在一个位置,则可以使用作为参数传递的UITableViewCell来确定发送方的indexPath:

- (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

}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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