tableView を追加し、テーブル ビュー セルをそこにドラッグしました。ユーティリティ パネルで、スタイルを字幕に変更しました。私はまた、コードでそれを変更しようとしました:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
}
cell.textLabel.textAlignment = UITextAlignmentCenter;
cell.detailTextLabel.textAlignment = UITextAlignmentCenter;
cell.textLabel.text = [myArray objectAtIndex:indexPath.row];
cell.detailTextLabel.text = [myArray2 objectAtIndex:indexPath.row];
return cell;
中央揃えがうまくいかない!
回避策として、セルにラベル オブジェクトを追加しようとしました。しかし、私はそれにアクセスする方法がわかりません。アウトレットを割り当てても、これは機能しません。
cell.labelForCell....
私は何をすべきか?セルなどにラベルを追加せずに、通常の方法で機能させる方法に関する提案はありますか?