简体   繁体   English

我如何知道用户是否单击了按钮?

[英]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.

相关问题 我如何知道点击UItableview中的Cell按钮 - how do i know what Cell's button in UItableview clicked 当我使用StoreKit的requestReview功能时,有没有办法知道用户是否点击了提交或不立即或取消按钮? - When I use requestReview function of StoreKit, is there any way to know if the user has clicked on Submit or Not Now or Cancel button? 我怎么知道 Instagram 按钮已被选中? - How do I know that the Instagram button has been selected? 我怎么知道用户点击了Static TableView中的节标题 - how can I know that the user clicked on the section header in Static TableView 在Xamarian iOS应用程序中单击按钮后X秒钟,如何触发事件? - How do I trigger an event X seconds after a button has been clicked in a Xamarian iOS application? 我如何知道用户是否已经接受/拒绝了 React-Native 的 ios 通知? - How do I know if a user has already accepted/refused ios notifications with React-Native? 我如何知道用户是否已收到来自privatepub gem的推送通知 - How do i know if user has received the push notification sent from privatepub gem SwiftUI 中的图像选择器 - 我如何知道用户何时在基于托管 UIkit 的 ViewController 中选择了图像 - Image Picker in SwiftUI - how do I know when the user has chosen an image in the hosting UIkit based ViewController 需要知道用户何时在iOS中单击键盘上的“返回” - Need to know when user has clicked 'return' on keypad in iOS UIStepper:如何知道用户点击了步进器的哪个按钮(减号或加号按钮) - UIStepper: how to be aware which button (minus or plus button) of the stepper has been clicked by user
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM