Ios UIWebView添加子视图UIButton按钮单击事件没有响应
这里,丹维尤解开了扣子 self是UIWebViewIos UIWebView添加子视图UIButton按钮单击事件没有响应,ios,objective-c,uiwebview,uibutton,Ios,Objective C,Uiwebview,Uibutton,这里,丹维尤解开了扣子 self是UIWebView _danView.frame = CGRectMake(windowWidth +randWindth, gaodu+[heiArr[i]intValue], size.width+40+(size.height+8)/2, size.height+8); _danView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"danmaku_bg"]];
_danView.frame = CGRectMake(windowWidth +randWindth, gaodu+[heiArr[i]intValue], size.width+40+(size.height+8)/2, size.height+8);
_danView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"danmaku_bg"]];
_danView.userInteractionEnabled = YES;
self.userInteractionEnabled = YES;
[_danView addTarget:self action:@selector(tapClick) forControlEvents:UIControlEventTouchUpInside];
_danView.layer.cornerRadius = (size.height+8)/2;
_danView.layer.masksToBounds = YES;
[self addSubview:_danView];
// [_danView addSubview:label];
[self animationWithView:_danView];
-(void)tapClick{
NSLog(@"click click");
}
使用
而不是
-(void)tapClick
UIWebView当然支持UIButton的addSubview,所以如果它不起作用,请检查代码。
我看到你制作了按钮的动画,移除动画并测试它的点击事件怎么样,也许你会发现问题。谢谢,我试图取消动画,但按钮仍然无法单击谢谢,打开webView是可以的。用户交互和我删除动画,但为什么不添加动画?因为你的代码没有问题,所以我猜错误来自动画。当然,它可以添加动画,也许只是你的动画代码有一些错误。也许你必须粘贴动画代码。
-(void)tapClick