Cocoa touch X按钮第二次单击属性
我在iPhone应用程序中有一个X按钮 单击一次会使X按钮变为红色。第二次单击它(X按钮变为红色后)执行取消操作 但是,如果有人单击X按钮(现在是红色)并在X按钮外单击,我希望它返回到原始状态Cocoa touch X按钮第二次单击属性,cocoa-touch,Cocoa Touch,我在iPhone应用程序中有一个X按钮 单击一次会使X按钮变为红色。第二次单击它(X按钮变为红色后)执行取消操作 但是,如果有人单击X按钮(现在是红色)并在X按钮外单击,我希望它返回到原始状态 我该怎么做?检查按钮外是否有触摸。如果button.isRed==TRUE,则应将其撤消。 希望足够清楚 假设您有ui按钮*closeButton。代码如下所示: - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{ [
我该怎么做?检查按钮外是否有触摸。如果
button.isRed==TRUE
,则应将其撤消。
希望足够清楚
假设您有ui按钮*closeButton
。代码如下所示:
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
[super touchesBegan:touches withEvent:event];
if ([touches anyObject].view == closeButton){
//User touched in the button!
} else {
//User touched outside the button
}
}
让我知道它是否工作。检查按钮外是否有触摸。如果
button.isRed==TRUE
,则应将其撤消。
希望足够清楚
假设您有ui按钮*closeButton
。代码如下所示:
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
[super touchesBegan:touches withEvent:event];
if ([touches anyObject].view == closeButton){
//User touched in the button!
} else {
//User touched outside the button
}
}
让我知道它是否有效。嗨,你可以试试这个(void)touchesedend:(NSSet*)toucheevent:(UIEvent*)event您可以试试这个..-(void)touchesend:(NSSet*)touchs with event:(UIEvent*)event“检查按钮外的触摸”--如何操作?当点击按钮时,这不起作用。在这种情况下,将触发唯一的按钮操作,将不会调用此方法。“检查按钮外的触摸”--如何?当点击按钮时,此方法不起作用。在这种情况下,只会触发按钮操作,不会调用此方法。