我正在尝试根据设备类型在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模拟器”,而不是“ iPhone”。更好的选择可能是基于[[UIDevice currentDevice] userInterfaceIdiom]
关于ios - iOS格式UITextView.text取决于设备类型,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/23552330/