複雑なことはしていません。表のセルにフォントを設定しようとしています。ビューコントローラーが表示された後にテーブルデータをリロードするか、テーブルがスクロールされてセルが更新された場合、フォントは正常に表示されます。しかし、最初にロードするときにテーブルビューのプロパティを設定しただけでは、正しく表示されません。
コードは次のとおりです。
-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
NSString *cellIdentifier = @"listItem";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (!cell) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
}
cell.textLabel.text = [pickerList objectAtIndex:indexPath.row];
return cell;
}
-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{
cell.backgroundColor = [UIColor AMFDarkBlueColor];
cell.selectionStyle = UITableViewCellSelectionStyleGray;
cell.textLabel.textColor = [UIColor AMFRedColor];
cell.textLabel.font = [UIFont fontWithName:@"MuseoSlab-500" size:cell.textLabel.font.pointSize];
}
reloadData
私が言ったように、私が電話すればうまくいきますviewDidAppear
。それは不必要なステップのように思えるので、何か間違ったことをしていないことを確認したい.
ありがとう
編集
フォントを設定しても同じ効果が得られcellForRowAtIndexPath
ますwillDisplayCell