2016-01-22 36 views
2

我使用objective-c编程iPhone应用程序。版本是在iOS 8.1之后。在我的UITableViewCell中有一些UITableViewRowAction,我点击UITableViewRowAction之一后发布请求,如果成功,我想更新按钮(UITableViewRowAction)无效,以便它不能再次点击。请帮助我,这很重要,但我没有办法解决。如何更新UITableViewRowAction中的按钮?

如图所示: 这是细胞,我们可以向左滑动

enter image description here

+0

您需要为每个单元手动维护一个状态。 如果用户点击您的操作按钮,保存该值。 当用户再次滑动单元格时,只需更改该按钮的背景颜色,不要为其写入动作块。 – iOSEnthusiatic

回答

0

后向左滑动

enter image description here

,我们可以看到三个按钮,我想你是需要使用UITableView代理方法

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath; 
+0

这个按钮并没有被UITableViewCell添加,它被添加为UITableViewRowAction,你会在幻灯片后看到它Cell left – user3196823

0

使用didSelectRowAtIndexPath方法发布您的请求。

在您的实现:

{ 
int selectedIndex; 
} 

然后:

- (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是,你必须设置为“YES”上的成功响应您的cell.h文件内声明的布尔值请求。

ie;在获得成功响应后,添加以下代码

YourCell *cell = (YourCell *)[tableView cellForRowAtIndexPath:selectedIndex]; 
cell.cellEnabled=YES; 
+0

我不想让UITableViewCell无效,我只想让按钮(UITableViewRowAction)无效 – user3196823

+0

你在说哪个按钮?它是否在单元格内?如果是这样,在获得成功响应时,添加以下代码。 YourCell * cell =(YourCell *)[tableView cellForRowAtIndexPath:selectedIndex]; cell.button.enabled = NO;如果可能的话, – abhi1992

+0

上传图片。 – abhi1992

相关问题