iOS 7模拟器错误 - NSAttributedString不会出现 [英] iOS 7 Simulator Bug - NSAttributedString does not appear

查看:197
本文介绍了iOS 7模拟器错误 - NSAttributedString不会出现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想我发现了一个bug iOS 7模拟器,其中未显示NSAttributedString。如果其他人可以测试这个以确认它是一个错误,那将是很好的,然后我将向Apple提交一个错误。

I think I have found a bug in the iOS 7 Simulator where a NSAttributedString does not appear. It would be great if someone else could test this to confirm it is a bug, then I will file a bug with Apple.

问题似乎是使用的组合NSAderlineStyleAttributeName和NSAttributedString的NSParagraphStyleAttributeName。

The problem appears to be the combination of using NSUnderlineStyleAttributeName and NSParagraphStyleAttributeName for NSAttributedString.

以下是重现的步骤:

1)在Xcode 5中创建一个新的单一视图应用程序。无论如何都要调用它。

1) In Xcode 5 create a new 'Single View Application'. Call it whatever.

2)在ViewController.m中,将viewDidLoad方法替换为:

2) In ViewController.m, replace the viewDidLoad method with:

- (void)viewDidLoad
{
    [super viewDidLoad];

    NSMutableParagraphStyle* paragraph = [[NSMutableParagraphStyle alloc] init];
    paragraph.alignment = NSTextAlignmentCenter;

    NSAttributedString* attrStr = [[NSAttributedString alloc] initWithString:@"Lorem ipsum dolor sit" attributes:
                                   @{NSUnderlineStyleAttributeName:@1,
                                     NSParagraphStyleAttributeName:paragraph}];

    UILabel* myLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 30, 0, 0)];
    myLabel.backgroundColor = [UIColor greenColor];
    myLabel.attributedText = attrStr;
    [myLabel sizeToFit];

    [self.view addSubview:myLabel];
}

3)在iOS 7设备上运行,然后在iOS中再次运行7模拟器。

3) Run on an iOS 7 device and then run it again in the iOS 7 simulator.

4)最后,将部署目标设置为iOS 6并在iOS 6模拟器上运行。

4) Lastly, set the deployment target to iOS 6 and run it on the iOS 6 simulator.

结果应如下所示


  • iOS 7设备:正确显示

  • iOS 7模拟器:仅显示标签背景

  • iOS 6模拟器:正确显示

屏幕截图:


iOS7设备



iOS7模拟器


iOS7 Simulator

推荐答案

看来这不是模拟器错误,而是iOS 7 bug,因为我现在能够在设备上重现它。我在这里创建了一个新问题: iOS 7 BUG - NSAttributedString不会出现

It appears this is not a Simulator bug, but an iOS 7 bug as I have been able to reproduce it on a device now. I have created a new question for it here: iOS 7 BUG - NSAttributedString does not appear

该错误似乎是使用NSUnderlineStyleAttributeName& NSParagraphStyleAttributeName作为NSAttributedString的属性。

The bug appears to be the combination of using NSUnderlineStyleAttributeName & NSParagraphStyleAttributeName as attributes for a NSAttributedString.

这篇关于iOS 7模拟器错误 - NSAttributedString不会出现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆