ios - .xib 中的许多 UIButton 具有不同的标签

标签 ios uibutton

我的 xib 中有 17 个按钮。我已将它们的标签值设置为 1 到 17。

有人可以告诉我,如何将所有 17 个按钮与 .h 中的单个变量名称连接起来,并在 .m 中获取带有标签值的特定按钮。

谢谢

最佳答案

我刚刚对此进行了测试,并且我知道如果您选择 Storyboard 中的所有按钮,并控制将它们拖到辅助编辑器中的适当 Controller ,您可以创建代表所有按钮的导出集合。生成的代码是:

@property (strong, nonatomic) IBOutletCollection(UIButton) NSArray *buttons;

关于ios - .xib 中的许多 UIButton 具有不同的标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10616811/

相关文章:

ios - 如何通过 get return 获取 IBInspectable var 值?

iphone - 从自定义 UITableViewCell 按钮获取按钮按下

ios - 以编程方式添加自定义 UIButton fatal error

ios - 由 UITapGestureRecognizer 创建的单击功能在 UIButton 上不起作用

ios - 点播资源 "leave the bundle"如何到达苹果服务器?

objective-c - 如何按日期对 NSMutableArray 键进行排序(Facebook 生日?)

ios - 处理按钮操作

ios - 通过 UIButton 将数据传递到另一个 Controller 上的 UITableView

ios - 如果相关对象更改,如何通知 NSFetchedResultsController

iOS - 使用 URL 方案打开某些 View Controller