如何让一个按钮做一个动作然后当我再次点击它另一个动作

时间:2014-04-13 01:47:43

标签: ios button uibutton action

好吧所以在我的Xcode项目中,我有一个按钮,我需要做两次相同的动作,但使用不同的图像Plz帮助

代码:     [UIView beginAnimations:nil context:nil];     [UIView setAnimationDuration:0.1];     Guy.frame = frame;     [UIView commitAnimations];

UIImage * toImage = [UIImage imageNamed:@"CharacterBackwards.png"];
[UIView transitionWithView:self.view
                  duration:0.01f
                   options:UIViewAnimationOptionTransitionNone
                animations:^{
                    self->Guy.image = toImage;
                } completion:NULL];

1 个答案:

答案 0 :(得分:-1)

尝试采用此伪代码

var firstCall = true

function action() {
    if (firstCall) {
        do_action_x()
        firstCall = false
    } else {
        do_action_y()
    }
}

基本上只是在同一个函数调用中使用具有不同值的变量。

相关问题