拾取器的尺寸隨着目標C,我用下面所示的代碼來設置拾取器的/改變字體系列和大小:改變字體及其在迅速
- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view {
UILabel* tView = (UILabel*)view;
if (!tView){
tView = [[UILabel alloc] init];
// Setup label properties - frame, font, colors etc
tView.font = [UIFont fontWithName:@"Times New Roman" size:fontsize];;
}
tView.text = [_mysitedata findKeyForRow:row];
NSLog(@"C key:%@ row:%ld comp:%ld", tView.text, (long int)row, (long int)component);
return tView;
}
然而,夫特不接受從UIView的轉換爲的UILabel,所以我不能走這條道路,其看起來像如下圖所示:
func pickerView(pickerView: UIPickerView, viewForRow row: Int, forComponent component: Int, reusingView view: UIView?) -> UIView {
let label = view as! UILabel
label.font = UIFont(name: "Times New Roman", size: 1.0)
label.text = pickerData[row]
return label
}
第一stament(讓標籤....)throuws在運行時異常:
EXC-BAD INSTRUCTION(代碼= EXC_I386_INVOP,子碼=爲0x0)
此鏈接[鏈接] http://stackoverflow.com/questions/27455345/uipickerview-wont-allow-changing-font-名稱和大小 - 通過代表 - 大小限制[>鏈接]解決了這個問題。 –