我只是添加一个带有按钮的快速介绍屏幕,它可以正确编译和显示,但我的按钮没有响应。
- (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!");
}
我在看什么?谢谢!