UIPickerView:NSAttributedString在iOS 7中不可用?

栏目: IOS · 发布时间: 6年前

内容简介:这个问题的唯一解决方案显然是使用pickerView:viewForRow:forComponent:reusingView:并返回带有属性文本的UILabel,因为Apple显然已禁用使用属性字符串.翻译自:https://stackoverflow.com/questions/18945119/uipickerview-nsattributedstring-not-available-in-ios-7
似乎UIPickerView不再支持将NSAttributedString用于选择器视图项.谁能证实这一点?我在UIPickerView.h文件中找到了NS_AVAILABLE_IOS(6_0),但这是问题吗?有没有办法解决这个问题,还是我运气不好?
- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component;
- (NSAttributedString *)pickerView:(UIPickerView *)pickerView attributedTitleForRow:(NSInteger)row forComponent:(NSInteger)component NS_AVAILABLE_IOS(6_0); // attributed title is favored if both methods are implemented
- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view;

这个问题的唯一解决方案显然是使用pickerView:viewForRow:forComponent:reusingView:并返回带有属性文本的UILabel,因为Apple显然已禁用使用属性字符串.

翻译自:https://stackoverflow.com/questions/18945119/uipickerview-nsattributedstring-not-available-in-ios-7


以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Web Form Design

Web Form Design

Luke Wroblewski / Rosenfeld Media / 2008-5-2 / GBP 25.00

Forms make or break the most crucial online interactions: checkout, registration, and any task requiring information entry. In Web Form Design, Luke Wroblewski draws on original research, his consider......一起来看看 《Web Form Design》 这本书的介绍吧!

在线进制转换器
在线进制转换器

各进制数互转换器

URL 编码/解码
URL 编码/解码

URL 编码/解码

RGB HSV 转换
RGB HSV 转换

RGB HSV 互转工具