0

我想在另一个 ViewController 的 UITableview 中禁用 UIButton:

我试过,在 SecondViewController 里面,但它只禁用了 _buttonDesc,buttonCell 仍然是启用的:

  • buttonCell 是 UITableView 内部的 Button。
  • buttonDesc 是 SecondViewController 内的 Button Comprar。

.

-(IBAction)comprar
{
    [_buttonDesc setTitleColor:[UIColor grayColor] forState:UIControlStateDisabled];
    [_buttonDesc setEnabled:NO];
    LivroCell *lvc = [[LivroCell alloc]init];

    [lvc.buttonCell setEnabled:NO];
}

在此处输入图像描述

4

1 回答 1

0

您需要对要禁用的实际 buttonCell 的引用。创建一个新的 LivroCell 实例对您没有帮助。

最简单的方法是当有人单击“购买”按钮时,您创建新的 UIViewController,传递对购买按钮的引用(如果“购买”调用 IBAction,然后将发送者传递给您创建的子视图控制器)。因此,在您的子视图控制器上创建一个属性来存储按钮,在您执行 alloc/init 时设置该属性,然后很容易稍后禁用。

于 2013-02-08T16:27:23.927 回答