OGeek|极客世界-中国程序员成长平台

标题: ios - 将按钮 socket 添加到 IBoutletCollection Xcode [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-12 10:58
标题: ios - 将按钮 socket 添加到 IBoutletCollection Xcode

我想将 15 个 UIButtons 添加到 IBOutletCollection 并分别更改每个 UIButton 的标签。我可以为每个按钮分配一个标签,然后以某种方式更改与按钮标签相关的按钮标签吗?或者他们需要单独的 socket 让我更改单独的按钮标签?



Best Answer-推荐答案


在按钮单击方法中编写此代码。设置 tag 并检查条件并设置 特定标签

title
-(IBAction)btnClickid)sender{

UIButton * btn = (UIButton *)sender;
int btag = btn.tag;

if(btag == 1)
    [btn setTitle"Your Title " forState:UIControlStateNormal];
else if (btag == 2)
     [btn setTitle"Your Title " forState:UIControlStateNormal];
}

关于ios - 将按钮 socket 添加到 IBoutletCollection Xcode,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25074899/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://ogeek.cn/) Powered by Discuz! X3.4