UILabelオブジェクトのプロパティを設定できません。UILabelプロパティを設定できません。
次のコードは、- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
方法である:
UILabel *label = (UILabel *)[cell viewWithTag:0];
label.text = [self.comments objectAtIndex:indexPath.row*2];
label.textColor = [UIColor cyanColor];
label.adjustsFontSizeToFitWidth = YES;
私が得るすべては、4行目のランタイムエラーです(不思議なことに、前の行はOKです):
2011-06-29 11:23:57.641 Esker Monitor[94138:207] -[UITableViewCell setAdjustsFontSizeToFitWidth:]: unrecognized selector sent to instance 0x4e889e0
2011-06-29 11:23:57.642 Esker Monitor[94138:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UITableViewCell setAdjustsFontSizeToFitWidth:]: unrecognized selector sent to instance 0x4e889e0'
似ラベルlabel.numberOfLines = 1;
やlabel.minimumFontSize = 7.0;
のようなプロパティの変更もプログラムをクラッシュさせます。
私はここで分かりにくいものがありますか?
'viewWithTag:'は 'UITableViewCell'オブジェクトを返すようです。 'text'と' textColor'も 'UITableViewCell'の(deprecated)プロパティであるため、前の行はOKです。 – albertamg
私は[Appleのチュートリアル](http://goo.gl/qQhuY)に続きました。彼らはその問題について話しません。 'viewWithTag:'によって返されたUIViewからUILabelを取得する方法はありますか? –
すべてのビューにはデフォルトとして0タグがありますので、別の値を使用することができます。 – albertamg