Objective c 代码中添加的UIButton不响应触摸

Objective c 代码中添加的UIButton不响应触摸,objective-c,ios,Objective C,Ios,我只是添加了一个带有按钮的快速介绍屏幕,可以正确编译和显示,但我的按钮没有响应 - (void)viewDidLoad { [super viewDidLoad]; NSLog(@"viewDidLoad!"); [self showIntro]; } // make a quick Intro screen - (void) showIntro { UIImageView *myBackImage = [[UIImageView alloc] initWithFra

我只是添加了一个带有按钮的快速介绍屏幕,可以正确编译和显示,但我的按钮没有响应

- (void)viewDidLoad {
   [super viewDidLoad];
   NSLog(@"viewDidLoad!");
   [self showIntro];
}

//  make a quick Intro screen
- (void) showIntro {
   UIImageView *myBackImage = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 320, 460)];
   [myBackImage setImage:(UIImage *) [UIImage imageNamed:@"myBkgnd.png"]];

   UIButton *clickBtn = [UIButton buttonWithType:UIButtonTypeCustom ];
   [clickBtn addTarget:self action:@selector(myButton_pressed:) forControlEvents:UIControlEventTouchUpInside];
   [clickBtn setImage:(UIImage *) [UIImage imageNamed:@"btnImage.png"] forState:UIControlStateNormal];
   clickBtn.frame = CGRectMake(111, 200, 75, 60);
   [myBackImage addSubview:clickBtn];
   [self.view addSubview:myBackImage];
}

- (void)myButton_pressed:(UIButton*)button {
   NSLog(@"Button Pressed!");
}
我忽略了什么?
谢谢

您在
UIImageView
中添加了
ui按钮
,但您没有忘记
imageView的
用户交互
,因为
默认无
。因此:

myBackImage.userInteractionEnabled = YES;

编辑:刚格式化

尝试对UIButton使用initWithFrame构造函数,而不是buttonWithType。