iphone - iOS 7多空格问题

标签 iphone ios ios6 nsstring ios7

我需要使用@"text . ", @"text . ", @"text . ", @"text ."为标签文本设置动画

因此用户只会看到点动画。我对标签文本使用中心对齐方式。

我为此使用计时器:

- (void)processTimerFired:(NSTimer *)timer {
    NSMutableDictionary *dict = [timer userInfo];
    NSMutableString *string = [[dict objectForKey:@"label"] mutableCopy];
    int dotNumber = [[dict objectForKey:@"dot"] intValue];
    if (dotNumber == 3) {
        dotNumber = 1;
    }
    else {
        dotNumber += 1;
    }

    [dict setObject:@(dotNumber) forKey:@"dot"];

    for (int i = 1; i < 4; i++) {
        if (i == dotNumber) {
            [string appendString:@"."];
        }
        else {
            [string appendString:@" "];
        }
    }

    self.informationLabel.text = string;
}

在iOS 6上,一切正常,但在iOS 7上,xcode似乎减少了空格数量,因此文本的来源始终变得不同。这就是为什么文本似乎动摇了。

我试图在测试末尾添加“+”。一切都OK。因此,似乎只有当xcode之后没有其他符号时,xcode才会删除“多余”空格。

最佳答案

如果用Unicode不可破坏的空格@" "(在Mac上由Alt-space获取)替换空格@" "怎么办?

关于iphone - iOS 7多空格问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19176497/

相关文章:

iphone - AVAudioSession后台模式问题

objective-c - 使用 CHCSVWriter 保存 CSV 文件

iphone - 上传图像到服务器,接收旋转图像

ios - 在 iOS 中分析 Assets.car 文件

iphone - 在 iPhone 中缩放和保存照片库中的 UIImage?

iphone - 避免 iPhone 应用程序崩溃的提示和技巧

ios - 上传到S3存储桶Swift 3问题

ios - iOS 中 Core Data 集成中的正向和反向映射是什么

iphone - 根据文本自动调整 UITextView

iphone - Cocos2d iOS : Why doesn't my CCMenuItemImage respond to touch events?