ios - button能显示,但是没有点击事件,怎么处理
本文介绍了ios - button能显示,但是没有点击事件,怎么处理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
问 题
-
(id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {imgView=[[UIImageView alloc] initWithFrame:CGRectMake(0.f, 0.f, 1024.f, 768.f)]; imgView.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleRightMargin; imgView.backgroundColor=[UIColor clearColor]; [imgView setImage:[UIImage imageNamed:@"tupian.jpg"]]; [self addSubview:imgView]; //[imgView.bringSubviewToFront];
closeButton = [[UIButton alloc] initWithFrame:CGRectMake(900.f, 100.f , 40.f, 40.f)]; closeButton.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin; [closeButton setTitle:@"touch" forState:UIControlStateNormal]; [closeButton addTarget:self action:@selector(closeClick) forControlEvents:UIControlEventTouchUpInside]; [closeButton setBackgroundImage:[UIImage imageNamed:@"close"] forState:UIControlStateNormal]; [self addSubview:closeButton];
}
return self;
} (void)layoutSubviews
{
[super layoutSubviews];
}
-
(void)closeClick
{NSLog(@" 广告"); [self.ADViewDelegate addADView]; [imgView removeFromSuperview];
}
解决方案
看看 self.userInteractionEnabled 是不是为 YES。
这篇关于ios - button能显示,但是没有点击事件,怎么处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文