在我的應用程序的方法,我需要在標籤中顯示下一行文字所以我用下面的代碼顯示下劃線的文字響應於選擇器不支持的實施
NSMutableAttributedString *attributeString = [[NSMutableAttributedString alloc] initWithString:normalString];
[attributeString addAttribute:NSUnderlineStyleAttributeName
value:[NSNumber numberWithInt:1]
range:(NSRange){0,[attributeString length]}];
wesiteAddressLabel.attributedText = attributeString;
這種方法和工作正常一些其他實現在iOS的6.1
但是,當我在的iOS 5.1執行及以下,應用進行了由於墜毀的原因,
[attributeString addAttribute:NSUnderlineStyleAttributeName
value:[NSNumber numberWithInt:1]
range:(NSRange){0,[attributeString length]}];
在以前的版本
所以我想用respondsToSelector:
方法來檢查實例響應和執行不支持的選擇另一種方法不支持。
我如何使用這種方法?