iOS报错terminate_handler unexpectedly threw an exception
来源:互联网 发布:php curl 查看请求头 编辑:程序博客网 时间:2024/06/06 11:38
今天遇到了一个非常奇葩的坑,但是我又不得不承认这也算是一个bug。由于感觉这可能是万分之一的踩坑概率,所以我想把这个记录下来,万一有和我一样莫名其妙被坑的人呢,嘿嘿......
早上有公司小姑娘找我说这个页面闪退,打不开。我默默拿出自己的手机试了一下,简直是完美无bug,并没有她说的闪退。我设想了各种可能,也许是她的账号数据的问题,或者她手机内存不足吧之类的。结果用我的手机登录了她的账号之后,并没有闪退,这就排除了账号问题。于是我用她的手机断点调试了一下,报错terminate_handler unexpectedly threw an exception,而且就崩溃在了下面这段代码块。于是我把这个代码注释了之后她的手机终于不闪退了。这个时候真相浮出了水面,这个姑娘手机的语言设置的是德语!!!(摊手)德国回来的妹子就是洋气。。。。。。于是我长了见识,德语中的小数点是逗号,类似100,00这种写法。所以为了迎合小姑娘用德语的心愿,我不得不加了一下判断。
下面介绍一下具体实现的方法。
+ (NSMutableAttributedString *)setAmountStringRoundNumberColor:(UIColor *)roundColor font:(UIFont *)roundFont DecimalNumberColor:(UIColor *)decimalColor font:(UIFont *)decimalFont TotalString:(NSString *)totalString{ NSMutableAttributedString *attributedStr = [[NSMutableAttributedString alloc] initWithString:totalString]; // 整数部分 NSRange range; if([totalString rangeOfString:@"."].location !=NSNotFound)//_roaldSearchText { range = [totalString rangeOfString:@"."]; } else { range = [totalString rangeOfString:@","]; } NSString *rangeString = [totalString substringToIndex:range.location + 1]; NSRange roundRange = [totalString rangeOfString:rangeString options:NSBackwardsSearch]; [attributedStr addAttribute:NSForegroundColorAttributeName value:roundColor range:roundRange]; [attributedStr addAttribute:NSFontAttributeName value:roundFont range:roundRange]; // 小数部分 NSString *leftString = [totalString substringFromIndex:range.location + 1]; rangeString = [totalString substringWithRange:NSMakeRange(range.location + 1, leftString.length - 1)]; NSRange decimalRange = [totalString rangeOfString:rangeString options:NSBackwardsSearch]; [attributedStr addAttribute:NSForegroundColorAttributeName value:decimalColor range:decimalRange]; [attributedStr addAttribute:NSFontAttributeName value:decimalFont range:decimalRange]; return attributedStr;}
阅读全文
0 0
- iOS报错terminate_handler unexpectedly threw an exception
- libc++abi.dylib: terminate_handler unexpectedly threw an exception 报错
- terminate_handler unexpectedly threw an exception
- iOS libc++abi.dylib: terminate_handler unexpectedly threw an exception
- 解决报错libc++abi.dylib: terminate_handler unexpectedly threw an exception
- libc++abi.dylib: terminate_handler unexpectedly threw an exception错误解决方案
- libc++abi.dylib: terminate_handler unexpectedly threw an exception错误小结
- libc++abi.dylib: terminate_handler unexpectedly threw an exception错误
- libc++abi.dylib: terminate_handler unexpectedly threw an exception
- libc++abi.dylib: terminate_handler unexpectedly threw an exception错误小结
- libc++abi.dylib: terminate_handler unexpectedly threw an exception错误小结
- libc++abi.dylib: terminate_handler unexpectedly threw an exception 问题解决
- 151128libc++abi.dylib: terminate_handler unexpectedly threw an exception错误
- libc++abi.dylib: terminate_handler unexpectedly threw an exception错误小结
- 解决libc++abi.dylib: terminate_handler unexpectedly threw an exception(1)
- libc++abi.dylib: terminate_handler unexpectedly threw an exception
- libc++abi.dylib: terminate_handler unexpectedly threw an exception错误
- UIActionSheet :libc++abi.dylib: terminate_handler unexpectedly threw an exception
- EPS是浮点相对误差限
- JQ实现效果:点击(or鼠标滑过)连接时显示内容,再点击(鼠标滑出)连接时隐藏内容
- js时间戳转日期
- 自留问题
- [Lintcode]主元素
- iOS报错terminate_handler unexpectedly threw an exception
- react native45版本开始后,新建应用会抛出UNpackage xxxx
- java中的 instanceof
- 单例设计模式
- 【MySQL数据库】安装MySQL5.7.18图文教程(以windows为例)
- 递归遍历指定深度的树状数据结构
- 那些年遇到的ajax相关问题
- java基础教程:常用对象之日期处理类(24)
- Some python print