[英]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.