我在 UIView 中有一个 UIButton,它位于我从 .xib 文件分配和初始化的 UIViewController 中。
当将 IBAction 连接到 UIButton 的“Touch Down”事件时,它会正确触发。但是,如果我将它连接到“Touch Up Inside”事件,它不会响应。
其他事件也不起作用。“Touch Drag Enter”、“Touch Drag Exit”、“Touch Up Outside”等。仅 Touch Down。
有谁知道为什么会这样?
该按钮是视图控制器中的一个简单的圆角矩形按钮。我已经加载了视图控制器:
-(void) pushNewViewController
{
MyViewController* newViewController = [[MyViewController alloc] initWithNibName:@"MyViewController" bundle:nil];
[self.view addSubview:newViewController.view];
[newViewController release];
}
我在 IB 中将此按钮添加到 MyViewController 的圆角矩形按钮。我创建了以下 IBActions:
-(IBAction) buttonTouchDown:(id)sender
{
NSLog(@"Button Touch Down Event Fired.");
}
-(IBAction) buttonTouchUpInside:(id)sender
{
NSLog(@"Button Touch Up Inside Event Fired.");
}
在 IB 菜单中,单击按钮并将 Touch Down 插座拖到 MyViewController 并选择 buttonTouchDown:。保存了 IB xib。
当我运行并测试按钮并收到“Button Touch Down Event Fired”日志消息时。
但是当我回到 IB 并将 Action 更改为 Touch Up Inside 并将其连接到 buttonTouchUpInside: IBAction 并保存时。我再次测试,我没有得到任何回应。
问候,丰富