原文地址:http://hi.baidu.com/xf151362z/item/f370c9cef743331b0ad93a09
问题:
将一个UIButton 放在一个UIImageView上面,然后将这个UIImageView放在self.view上面,之前给UIButton添加的[button_buy addTarget:self action:@selector(buyButton) forControlEvents:UIControlEventTouchUpInside]响应事件,可怎么就是不响应
原因:
UIView的userInteractionEnabled默认是YES
而UIImageView的userInteractionEnabled默认是NO
解决方法:
UIImageView有一个属性userInteractionEnabled,把他设成yes就行了。否则UIImageView不能识别点击动作。
本文解决了UIButton放置于UIImageView上时点击事件不响应的问题。原因是UIImageView默认不处理触摸事件,需将其userInteractionEnabled属性设置为YES。
484

被折叠的 条评论
为什么被折叠?



