目标C - 与多个连续的结果一个按钮 [英] Objective C - one button with multiple sequential outcomes

查看:178
本文介绍了目标C - 与多个连续的结果一个按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新来编程,因此任何帮助是AP preciated。我试图找到下面的方法。我需要一个按钮,将被执行时,在一个序列中被激活时执行不同的任务。例如,第一次,按钮pressed,我想它为,如果用户在确认按钮的标题信息的行为(即确认用户是45岁以上)。用户presses按钮第二次它证实在负的响应(即确认用户是年龄不超过45)。第三次用户presses按钮字段复位,并没有值已被分配(即,这是因为如果用户永远不会回答了这个问题)。

I am new to programing so any help is appreciated. I am trying to find the method for the following. I need one button that will, when executed, perform a different task in a sequence when activated. For example the first time that the button is pressed, I would like it to act as if the user is confirming the information in the title of the button (i.e. confirms that the user is older than 45). The second time that the user presses the button it confirms the response in the negative (i.e. confirms the user is NOT older than 45). The third time the user presses the button the field is reset and no value has been assigned (i.e. it is as if the user never answered the question).

有关房地产的目的,我想问题的信息是按钮的标题,一旦行动已被抓获适当的更新。例如,如果动作是正显示示出与周围的标题的圆。如果动作导致的否定响应时,标题被示为具有通过它的线。

For real-estate purposes I would like the information in question to be the title of the button and update appropriately once the action has been captured. For example, if the action is positive the display is shown with a circle around the title. If the action results in a negative response, the title is shown with a line through it.

我已经做了相当多或阅读,试图得到一个解决方案,但没有骰子为止。我试图覆盖与标签变化的文本标签上的一个按钮,但到目前为止,我没有任何运气

I have done quite a bit or reading to try to get a solution but no dice so far. I have tried overlaying a button on a label with the text of the label changing, but so far I am not having any luck

我不能成像,这是一个独特的问题,任何帮助是AP preciated。很多提前感谢。

I can't imaging that this is a unique issue and any help is appreciated. Much thanks in advance.

推荐答案

在该事件只是有一些code这样的

On the event just have some code like this

标题

    - (IBAction)buttonPressed:(id)sender{
       static int counter;


        if (counter == 0){
        // do stuff for first time Example [sender setTitle:@"45"];
        }else if (counter == 1){
        // do stuff for second time Example [sender setTitle:@"-45"];
        }else if (counter == 2){
        // do stuff for the third time
        }
        counter += 1;


       if (counter > 2){
         // restart the counter
         counter = 0;
    }
}

这篇关于目标C - 与多个连续的结果一个按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆