iOS 格式 UITextView.text 取决于设备类型

标签 ios uitextview viewdidload viewwillappear uidevice

我正在尝试根据设备类型格式化 TextView 中的文本,但它不起作用。 “其他条件”总是在模拟器中输出。这是因为viewDidLoad吗?

#import "Rules.h"

@implementation Rules

@synthesize rulesTextView;

- (void)viewDidLoad {
    [super viewDidLoad]       

    NSString *rulesText;
    NSString *deviceType = [UIDevice currentDevice].model;

    if([deviceType isEqualToString:@"iPhone"]){
        rulesText = @"2, 3, 4, 5, 6\t\t are counted as +1.\n7, 8, 9\t\t\t are counted as 0.\n10, J, Q, K, A\t are counted as -1.\n\nThe higher the plus count, the higher the percentage of ten-point cards and aces remaining to be dealt, meaning that the advantage is to player and they should increase their wager.\n\nIf the running count is around zero, the deck or shoe is neutral and neither the player nor the dealer has an advantage.\n\nThe higher the minus count, the greater the disadvantage is to the player, as a higher than normal percentage of low\ncards remain to be dealt. In this case a player should be making their minimum wager or leave the table.";
    }
    else{
        rulesText = @"2, 3, 4, 5, 6\t\t are counted as +1.\n7, 8, 9\t\t\t\t are counted as 0.\n10, J, Q, K, A\t are counted as -1.\n\nThe higher the plus count, the higher the percentage of ten-point cards and aces remaining to be dealt, meaning that the advantage is to player and they should increase their wager.\n\nIf the running count is around zero, the deck or shoe is neutral and neither the player nor the dealer has an advantage.\n\nThe higher the minus count, the greater the disadvantage is to the player, as a higher than normal percentage of low\ncards remain to be dealt. In this case a player should be making their minimum wager or leave the table.";
     }

    rulesTextView.text = rulesText;

}

最佳答案

是因为模拟器。模拟器上的模型是“iPhone Simulator”,而不是“iPhone”。更好的选择可能是基于 [[UIDevice currentDevice] userInterfaceIdiom]

关于iOS 格式 UITextView.text 取决于设备类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23552330/

相关文章:

ios - 如果我的应用程序不能在iPad 1上运行,苹果会拒绝吗?

swift - 表格 View 卡住了很多

ios - 如何从快速应用程序的键盘上完全删除隐藏/完成按钮?

iphone - iOS上UITextView中两行之间的前导或垂直距离

iOS View 保留数据

ios - 动画工具栏中的完整更改

ios - 从 Share Extension 打开 Container App

ios - 如何将 UI ImageView 从一个 View Controller 传递到另一个? swift 3

ios - 如何为每个语句添加一个对象数组

swift - Swift 中 Unresolved 标识符错误?