这里_danView是Unbutton
和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.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");
}
答案 0 :(得分:0)
UIWebView肯定支持UIButton的addSubview,所以如果它不起作用,请检查代码。
我看到你为按钮设置动画,如何删除动画并测试其点击事件,也许你会发现一些问题。
答案 1 :(得分:-2)
使用
- (IBAction)tapClick:(id)sender
而不是
-(void)tapClick