ios - 我如何知道用户是否点击了按钮?

标签 ios objective-c uibutton

确定用户点击了哪个按钮的最简单方法是什么?

我在做什么:

 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";
    }

最佳答案

你有你的按钮作为 IBOutlets 或者只是在本地创建

UIButton *btn1;
UIButton *btn2;
UIButton *btn3;

现在您可以选择将各个方法作为操作分配给这些按钮。但是,一个操作可能是以下操作:

- (IBAction)ButtonPressed:(UIButton*)sender
{
    if (sender == btn1) ...
    if (sender == btn2) ... 
    // and so on
}

感谢丹。 :-)

关于ios - 我如何知道用户是否点击了按钮?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36135148/

相关文章:

ios - 同时更改所有表格 View 单元格上的显示参数

iphone - 使用带有 XML 的字典 (iphone/iOs)

iphone - 从 NSURLRequest 返回一个字符串

ios - UIBUtton : what is it and how to remove it? 标题标签上的小黑边

ios - 设备旋转时 TableView Cell 中显示的两个 uibutton

ios - iOS中如何从CMSampleBufferRef获取Camera数据的当前捕获时间戳

iphone - 推送通知进入时的警报序列

ios - 以编程方式将键盘从大写切换为小写

objective-c - 如何将 NSArray 写入 NSOutputStream?

ios - UIButton 按住