UIPickerView の例外を何時間も追跡してきました。デリゲート メソッドの 1 つに絞り込みましたが、正直わかりません。iPhone にネイティブに付属するフォント ファミリのリストを取得し、それらのタイトルをピッカー ビューに表示するだけです。
-(NSAttributedString *)pickerView:(UIPickerView *)pickerView attributedTitleForRow:(NSInteger)row forComponent:(NSInteger)component
{
NSLog(@"attributedTitleForRow");
NSString *fontName = [self.fontFamilies objectAtIndex:row];
NSLog(@"Font: %@", fontName);
NSDictionary *attributes = @{NSFontAttributeName:fontName};
NSLog(@"Attributes: %@", attributes);
NSAttributedString *attributedString = [[NSAttributedString alloc] initWithString:fontName attributes:attributes];
NSLog(@"Returning %@", attributedString);
return attributedString;
}
プリントアウトを含む。例外:
2013-07-31 23:28:42.875 [4689:907] attributedTitleForRow
2013-07-31 23:28:42.876 [4689:907] Font: Thonburi
2013-07-31 23:28:42.879 [4689:907] Attributes: {
NSFont = Thonburi;
}
2013-07-31 23:28:42.881 [4689:907] Returning Thonburi{
NSFont = Thonburi;
}
2013-07-31 23:28:42.884 [4689:907] attributedTitleForRow
2013-07-31 23:28:42.886 [4689:907] Font: Snell Roundhand
2013-07-31 23:28:42.887 [4689:907] Attributes: {
NSFont = "Snell Roundhand";
}
2013-07-31 23:28:42.889 [4689:907] Returning Snell Roundhand{
NSFont = "Snell Roundhand";
}
2013-07-31 23:28:42.892 [4689:907] attributedTitleForRow
2013-07-31 23:28:42.894 [4689:907] Font: Academy Engraved LET
2013-07-31 23:28:42.896 [4689:907] Attributes: {
NSFont = "Academy Engraved LET";
}
2013-07-31 23:28:42.898 [4689:907] Returning Academy Engraved LET{
NSFont = "Academy Engraved LET";
}
2013-07-31 23:28:42.920 [4689:907] -[__NSCFConstantString screenFontWithRenderingMode:]: unrecognized selector sent to instance 0x3977f364
2013-07-31 23:28:42.922 [4689:907] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFConstantString screenFontWithRenderingMode:]: unrecognized selector sent to instance 0x3977f364'