即使禁用了单元格,也启用AccessoryDe​​tailButton

时间:2011-10-10 13:19:43

标签: iphone objective-c xcode

我想禁用我的UITableViewCell,但仍然可以按下accessoryView按钮。

我认为这样可行:

cell.userInteractionEnabled = NO;
cell.accessoryView.userInteractionEnabled = YES;

但是我的UITableViewCellAccessoryDe​​tailDisclosureButton仍然被禁用。

4 个答案:

答案 0 :(得分:0)

accessoryView将从他的超级视图中获取所有的触摸事件,在这种情况下,您的单元格将对您的行为做出反应。

可能有效的方法是在viewController上创建一个touchment事件触摸事件,使viewView开启并使其对触摸作出反应。

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event;
{  
    UITouch *touch = [[event allTouches] anyObject];

    if ([touch view] == accessoryView) {
        //do something because you hit accessoryView
    }
}

答案 1 :(得分:0)

如果您停用某个视图,其所有子视图都将被停用。

答案 2 :(得分:0)

为此,您必须在Disclosure和cell中设置userInteractionEnabled = NO单元格中的所有子视图。

答案 3 :(得分:0)

cell.selectionStyle=UITableViewCellSelectionStyleNone;
cell.userInteractionEnabled = YES;

将此行放在此方法中。

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 


- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
   Leave this method blank. if u want to code in this delegate method so filter those row by code:  
 if(indexPath.row == row no in which u don't want click event)  
 {
    leave blank
 }
 else
 {
   code which u want .
 }
}

您可以在此方法中获取特定按钮的点击事件。

- (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath;
相关问题