UIButton 的选定状态在 iOS7 中不起作用

UIButton#39;s Selected State not working in iOS7(UIButton 的选定状态在 iOS7 中不起作用)
本文介绍了UIButton 的选定状态在 iOS7 中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Xcode 5 的故事板来创建一个应用程序,iOS SDK 7.0.

I am using Xcode 5's storyboarding to create an application, iOS SDK 7.0.

我将一个按钮拖到视图中.我希望我的按钮默认显示A".下面是按钮属性:类型:系统,状态配置:默认,标题:普通

I dragged a button to the View. I want my button to display "A" by Default. Below are the button properties: Type: System, State Config: Default, Title: Plain

我希望我的按钮在选定状态下显示B".因此,更改的按钮属性:状态配置:已选择

I want my button to display "B" in selected state. So, the button properties that changed: State Config: Selected

在 Button 的 Attribute 检查器中,在 Control 下,有一个名为 Selected 的属性.如果我选中 Selected,而不是显示B",它只是像 A 上的标记一样突出显示,即看不到任何字符.

In the Button's Attribute inspector, under the Control, there is a property called Selected. If I check Selected, instead of displaying "B", it just highlights like a marker over A, i.e, no character is seen.

我在 XCODE 中运行它.当未选择按钮时,A"按预期显示,但是当我选择按钮时,按钮的文本部分以浅蓝色突出显示,而不是显示 B.另外,我从来没有在控件下选择突出显示的内容.

I ran it in XCODE. WHen the button is not selected "A" is displayed as expected but when I select the button, instead of displaying B, the text portion of the button is highlighted with light blue color. Also, I never selected the Highlighted Content under the Control.

如何解决,才能正确显示状态?

How can this be resolved, so that I can display the state correctly?

推荐答案

您需要将 State Config 设置为 Selected 的同时将按钮的 title 设置为 'B'strong> 在你的故事板中.然后你需要将一个动作连接到按钮的 Touch Up Inside 事件.在该操作中,切换按钮的 selected 属性.

You need to set the title of the button to 'B' while you have State Config set to Selected in your storyboard. Then you need to connect an action to the button's Touch Up Inside event. Inside of that action, toggle the button's selected property.

当您在属性检查器下选中已选择"时,您只是将按钮的初始选择状态设置为是".XCode 还会向您展示按钮在该状态下的外观.

When you check 'Selected' under the Attributes Inspector, you are just setting the button's initial selected state to YES. XCode also shows you what the button would look like in that state.

这篇关于UIButton 的选定状态在 iOS7 中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

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

相关文档推荐

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菜单时获取事件)