zoukankan      html  css  js  c++  java
  • NSMutableAttributing相关 ios7升级ios8出现的问题

    项目在ios7上没有问题,但是升级ios8以后,出现了不少问题,其中一个追踪到就是在NSMutableAttributing的使用上出现的问题。

    项目中有个功能是:有一串字符串,对指定位置的字符设置不同的颜色,就是使用NSMutableAttributedString来实现的:

    NSMutableAttributedString *attibuttionStr = [[NSMutableAttributedString alloc] initWithString:str];

    [attibuttionStr addAttribute:(NSString *)NSForegroundColorAttributeName

                               value:(id)firstColor.CGColor

                               range:oneRange];

    在ios7上这样是能正常实现的

    但是ios8上除了问题,程序崩溃,提示“

    2014-09-23 13:30:50.224 RecordForStudy[17993:413448] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFType set]: unrecognized selector sent to instance 0x7fcbcba07090'

    最终找出,

    在ios8上用value:(id)firstColor.CGColor就会报错,

    改成value:(id)firstColor就好了。

    [attibuttionStr addAttribute:(NSString *)NSForegroundColorAttributeName

                               value:(id)firstColor

                               range:oneRange];

    这样就好了。

    总结:在ios7以及之前,value的值写

    1、(id)firstColor.CGColor

    或者直接写

    2、(id)firstColor

    都是没问题的,

    但是在ios8上只能写成2、(id)firstColor这种样式才是正确的

  • 相关阅读:
    zabbix 组信息
    perl tk说明
    perl tk说明
    haproxy ssl相关配置
    haproxy ssl相关配置
    haproxy 关闭ssl 3.0 加密
    haproxy 关闭ssl 3.0 加密
    【华为敏捷/DevOps实践】4. 如何从Excel做项目管理的方式中走出来
    【华为云实战开发】13.如何在云端快速搭建python网站
    【华为云实战开发】12.如何在云端快速开展Swagger接口测试
  • 原文地址:https://www.cnblogs.com/guatiantian/p/3988184.html
Copyright © 2011-2022 走看看