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

时间:2014-05-08 20:53:53

标签: 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;

}

1 个答案:

答案 0 :(得分:3)

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