2

I use objective-c programming iPhone App. version is after iOS 8.1. there are some UITableViewRowAction in my UITableViewCell, i post request after tapping one of UITableViewRowAction, if successful, i want update the button (UITableViewRowAction) to be invalid so that it can not be tapped again. please help me, it is important ,but i have no solution.

as shown in figure: this is the cell we can swipe left

enter image description here

we can see the three buttons after swiping left

enter image description here

abhimuralidharan
  • 5,752
  • 5
  • 46
  • 70
  • You need to maintain a state manually for every cell. Save the value if user clicks on your action button. When user swipes the cell again simply change background color of that button and do not write action block for that. – rushisangani Jan 22 '16 at 11:47

2 Answers2

0

i think you are need to use UITableView delegate method

 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath;
Rushi trivedi
  • 737
  • 1
  • 15
  • 37
  • the button is not added by UITableViewCell, which is added as UITableViewRowAction, you will see it after slide Cell left – user3196823 Jan 22 '16 at 11:16
0

Use the didSelectRowAtIndexPath method to post your request.

In your implementation:

{
int selectedIndex;
}

Then:

 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
    {
       selectedIndex=indexPath.row;

        YourCell *cell = (YourCell *)[tableView cellForRowAtIndexPath:selectedIndex];
        if(cell.cellEnabled)
        {
        //Your request goes here...
        }
        else
       {
      //The cell is disabled..
        }
  }

cellEnabled is a BOOL value declared inside your cell.h file that you have to set to "YES" on successful response of the request.

ie; on getting success response, add the following code

YourCell *cell = (YourCell *)[tableView cellForRowAtIndexPath:selectedIndex];
cell.cellEnabled=YES;
abhimuralidharan
  • 5,752
  • 5
  • 46
  • 70