我正在尝试向UIButton添加子视图。这现在运行得很好。但是一旦我添加子视图,这个按钮就不能再点击了。
我使用以下代码:
UIButton * button = [UIButton buttonWithType:UIButtonTypeCustom];
button.frame = CGRectMake(column*100+24, row*80+10, 64, 64);
[button addSubview:asyncImage];
[button addSubview:price];
[button addTarget:self
action:@selector(buttonClicked:)
forControlEvents:UIControlEventTouchUpInside];如果我剪掉两个addsubview,这个按钮就会再次工作。如果有人知道如何解决这个问题,那就太好了!
THNX!
发布于 2011-07-13 17:13:28
我找到了一个快速的解决方案。我需要将asyncimageview设置为:
asyncImage.userInteractionEnabled = NO;
asyncImage.exclusiveTouch = NO;在这之后,它起作用了!
发布于 2011-07-13 15:02:23
尝试:
[UIButton buttonWithType:UIButtonTypeCustom];
而不是:
[UIButton buttonWithType:UIButtonControlType];
发布于 2011-07-13 15:03:02
你有没有试过把:
[asyncImage setUserInteractionEnabled:YES];https://stackoverflow.com/questions/6675233
复制相似问题