UIButton setFont在iPhone 2G iOS 3.1.3上失败

时间:2011-03-27 12:22:04

标签: iphone uibutton uifont

我的测试人员在iPhone 2G中使用iOS 3.1.3。应用程序在他的手机上崩溃了这个方法:

- (void) viewDidLoad 
{
    [super viewDidLoad];

    [resumeGame.titleLabel setFont:[UIFont fontWithName:@"Old English Text MT" size:20.0]];
    [startNewGame.titleLabel setFont:[UIFont fontWithName:@"Old English Text MT" size:20.0]];
    [options.titleLabel setFont:[UIFont fontWithName:@"Old English Text MT" size:20.0]];   
}        

接口:

@interface PuzzleViewController : UIViewController 
{
    IBOutlet UIButton *resumeGame;
    IBOutlet UIButton *startNewGame;
    IBOutlet UIButton *options;
}

@property (nonatomic, retain) IBOutlet UIButton *resumeGame;
@property (nonatomic, retain) IBOutlet UIButton *startNewGame;
@property (nonatomic, retain) IBOutlet UIButton *options;

将字体复制到Resources文件夹中,并正确设置“Info.plist”“应用程序提供的字体”。

知道如何解决这个问题吗?

2 个答案:

答案 0 :(得分:4)

根据documentation on UIKit Keys,自定义字体在iOS 3.2中变得 。这很可能是您的代码在iOS 3.1.3上失败的原因(或者在当天被称为iPhone OS 3.1.3)。

答案 1 :(得分:1)

首先,我想告诉大家,很少有人使用iPhone 2G和iOS 3.1.3。事实上,很少有人使用iOS 4.0以下的任何东西。除非客户明确要求,否则我们通常不支持4.0以下的任何内容。如果我们在较低版本的iOS上发现错误,我们就会放弃对该版本的支持,因为它不值得花时间来修复它。

如果您仍然决定要修复此错误,那么您将需要提供堆栈跟踪,否则我们将很难告诉您出现了什么问题。

编辑:正如Bartosz指出的那样,您使用的是iOS 3.1.3中没有的功能。如果您需要自定义字体,则无法支持3.2以下的任何内容。 iOS 3.2仅适用于iPad,因此如果您的应用仅限iPhone,则意味着您不会支持4.0以下的任何内容。正如我在原始答案中所指出的,大多数用户都使用> = 4.0。