IOS 的最佳单选按钮实现

Best radio-button implementation for IOS(IOS 的最佳单选按钮实现)
本文介绍了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 的最佳单选按钮实现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Why local notification is not firing for UNCalendarNotificationTrigger(为什么没有为UNCalendarNotificationTrigger触发本地通知)
iOS VoiceOver functionality changes with Bundle Identifier(IOS画外音功能随捆绑包标识符而变化)
tabbar middle tab out of tabbar corner(选项卡栏中间的选项卡角外)
Pushing UIViewController above UITabBar(将UIView控制器推送到UITabBar上方)
How can I sync two flatList scroll position in react native(如何在本机Reaction中同步两个平面列表滚动位置)
Get an event when UIBarButtonItem menu is displayed(显示UIBarButtonItem菜单时获取事件)