UIButton#39;s Selected State not working in 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 中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:UIButton 的选定状态在 iOS7 中不起作用


基础教程推荐
- Android:getLastKnownLocation(LocationManager.NETWORK_PROVIDER 2022-01-01
- 通过重定向链接在 Google Play 中打开应用 2022-01-01
- Cocos2d iPhone 非矩形精灵触摸检测 2022-01-01
- AdMob 广告未在模拟器中显示 2022-01-01
- iPhone - 获取给定地点/时区的当前日期和时间并将其与同一地点的另一个日期/时间进行比较的正确方法 2022-01-01
- iOS4 创建后台定时器 2022-01-01
- navigator.geolocation.getCurrentPosition 在 Android 浏览器上 2022-01-01
- libGDX 从精灵或纹理中获取像素颜色 2022-01-01
- 如何从 logcat 中删除旧数据? 2022-01-01
- NSString intValue 不能用于检索电话号码 2022-01-01