[英]How do I know if the user has clicked on a button?
What is the easiest way to determine which button was clicked by the user? 确定用户单击哪个按钮的最简单方法是什么?
What I am doing: 我在做什么:
if((themeSeclection.highlighted = YES)){
informationView.text =@"This is test";
}
if((caputreImage.highlighted = YES)){
informationView.text =@"This is another test";
}
if((switchCamera.highlighted = YES)){
informationView.text =@"Test 3";
}
You have got your buttons as IBOutlets
or just locally created 您已将按钮作为
IBOutlets
或仅在本地创建
UIButton *btn1;
UIButton *btn2;
UIButton *btn3;
Now you have the option to assign individual methods as actions to these buttons. 现在,您可以选择将各个方法作为操作分配给这些按钮。 However, one action would to, which may be the following:
但是,将采取以下措施:
- (IBAction)ButtonPressed:(UIButton*)sender
{
if (sender == btn1) ...
if (sender == btn2) ...
// and so on
}
Credits go to dan. 学分去丹。 :-)
:-)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.