簡體   English   中英

NSMutableDictionary設置值在iOS 5上崩潰

[英]NSMutableDictionary setting value crashes on iOS 5

我有以下代碼:

 NSMutableDictionary *attributes = [NSMutableDictionary dictionary];
    [attributes setValue:[UIColor colorWithRed:86.0/255.0 green:134.0/255.0 blue:172.0/255.0 alpha:1.0] forKey:NSForegroundColorAttributeName];

它在iOS 6上正常工作,但在iOS 5上崩潰。知道為什么嗎?

NSForegroundColorAttributeName僅在iOS6中可用。

http://developer.apple.com/library/ios/#Documentation/UIKit/Reference/NSAttributedString_UIKit_Additions/Reference/Reference.html

所有NSAttributedString僅限於iOS6。

NSAttributedString UIKit的添置參考NSForegroundColorAttributeName說:

NSForegroundColorAttributeName

此屬性的值是UIColor對象。 使用此屬性可以指定渲染期間文本的顏色。 如果未指定此屬性,則文本將顯示為黑色。

在iOS 6.0及更高版本中可用。

在NSAttributedString.h中聲明。

因此,此屬性僅在iOS 6及更高版本中可用。 實際上, NSAttributedString UIKit Additions中的所有內容都是iOS 6及更高版本。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM