-
(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。