所以我有一个 UIView,我称之为 ctrView,这个 ctrView 被添加到我的 UIViewController 的视图中。它基本上只是一个较小的矩形框架。我在这个容器视图的右上角添加了一个 UIButton,但是似乎在单击 ctrView 之外的 UIButton 区域时不会触发与按钮相关的操作。只有容器视图内的 UIButton 区域会触发操作。我该如何解决这个奇怪的问题?
UIButton *closeButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
[closeButton setImage:[UIImage imageNamed:@"close.png"] forState:UIControlStateNormal];
[closeButton setBackgroundColor:[UIColor clearColor]];
[closeButton addTarget:self action:@selector(closeZoomedImageView) forControlEvents:UIControlEventTouchUpInside];
[closeButton setCenter:CGPointMake(ctrView.frameX + ctrView.frameWidth - 30, ctrView.frameY - 15)];
[ctrView addSubview:closeButton];
[closeButton release];