私は自分のアプリでこのコードを書いています:
- (IBAction)ZoomInFunction{
@try{
UITextField *test = (UITextField *)[self.view viewWithTag:indexNews];
NSLog(@"INDEX NEWS : %d", indexNews);
UIFont *font = test.font;
if(test.font == [font fontWithSize:22])
test.font = [font fontWithSize:22];
else
test.font = [font fontWithSize:font.pointSize+2];
}@catch (NSException *err) {
NSLog(@"Error handler : %@", err);
}
}
- (IBAction)ZoomOutFunction{
@try {
UITextField *test = (UITextField *)[self.view viewWithTag:indexNews];
UIFont *font = test.font;
if(test.font == [font fontWithSize:14])
test.font = [font fontWithSize:14];
else
test.font = [font fontWithSize:font.pointSize-2];
}@catch (NSException *err) {
NSLog(@"Error handler : %@", err);
}
コードが正常に実行される場合もありますが、エラーが次のように表示される場合もあります。
エラー ハンドラー: -[UIView フォント]: 認識されないセレクターがインスタンス 0xac70780 に送信されました