IOS 的最佳单选按钮实现 [英] Best radio-button implementation for IOS

查看:15
本文介绍了IOS 的最佳单选按钮实现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想问一下是否有关于如何在 iPhone 应用上实现单选按钮选项的示例.

我发现 Picker View 对于一个简单的选择功能来说相当大.

我不确定 Apple 是否故意排除了单选按钮,以及从可用性/用户体验的角度来看,简单地使用 Picker View 是否更好.

解决方案

我对最好的单选按钮实现应该是什么样子有一些想法.它可以基于 UIButton 类并使用它的选定"状态来指示组中的一个.UIButton 在 IB 中有原生的自定义选项,所以设计 XIB 很方便.还应该有一种使用 IB 插座连接对按钮进行分组的简单方法:

我已经在这个 .

I would like to ask if there are examples out there on how to implement radio-button options on an iPhone app.

I find the Picker View quite big for a simple selection feature.

I'm not sure if Apple excluded radio buttons on purpose, and whether if it is better to simply use a Picker View from a usability / user experience point-of-view.

解决方案

I have some thoughts on how the best radio button implementation should look like. It can be based on UIButton class and use it's 'selected' state to indicate one from the group. The UIButton has native customisation options in IB, so it is convenient to design XIBs. Also there should be an easy way to group buttons using IB outlet connections:

I have implemented my ideas in this RadioButton class. Works like a charm:

Download the sample project.

这篇关于IOS 的最佳单选按钮实现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆