繁体   English   中英

可滑动按钮动作

[英]Swipe-able Button Action

我正在开发用于音乐应用程序的应用程序。 主要思想是使应用看起来像是新事物。 我有一个表格,表格有它自己的单元格。 我为该单元格创建了Swipeable方法,因此,当用户向右滑动时,应显示“下载”按钮;当用户向左滑动时,应显示“播放”按钮。 在为这些按钮提供一些特定操作方面,有人可以帮忙吗? 我可以添加警报或视图,但是我不知道如何专门为“播放/暂停”按钮添加动作?

我正在使用下面的代码?

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

====更新====

我想为Music Player创建一个APP,所以问题是我是否具有通常带有动态或静态单元格的单元原型。 这些单元格可以向左和向右滑动。

现在,当我想向右滑动时,按钮应显示“下载”,如果向左滑动,则按钮应显示“播放/暂停”,并在按下按钮后开始播放歌曲。

让我知道是否清楚。

假设您的问题是“如何将所有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