本文主要是介绍UIImageView上添加Button不能响应点击事件,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
UIImageView *backImageView = [[UIImageView alloc]initWithFrame:CGRectMake(0,self.view.frame.size.height-UITABBAR_HEIGHT-216-39, 320, 43) ];
[backImageView setUserInteractionEnabled:YES];//使添加其上的button有点击事件
[backImageView setImage:[UIImage imageNamed:@"navigationBar.png"]];
[backScroll addSubview:backImageView];
UIButton *loginButton = [UIButton alloc];
[loginButton setFrame:CGRectMake(10, 0, 40, 43)];
[loginButton setTitle:@"hello" forState:UIControlStateNormal];
[loginButton addTarget:self action:@selector(loginOrLogout) forControlEvents:UIControlEventTouchUpInside];
[backImageView addSubview:loginButton];
这篇关于UIImageView上添加Button不能响应点击事件的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!