UITableViewCellSTyleValue1を使用したuitableviewがあるので、テキストラベルと詳細テキストラベルがあります。
私が持っている2番目のものはNSMutableArrayです。ここで、textLabelsに偶数の項目を入力し、detailTextlabelsに奇数のエントリを入力します。
したがって、たとえば、セル1(ゼロ)はエントリ0を取得し、セル1は2と3を取得します。
今まで動かなかった。
UITableViewCellSTyleValue1を使用したuitableviewがあるので、テキストラベルと詳細テキストラベルがあります。
私が持っている2番目のものはNSMutableArrayです。ここで、textLabelsに偶数の項目を入力し、detailTextlabelsに奇数のエントリを入力します。
したがって、たとえば、セル1(ゼロ)はエントリ0を取得し、セル1は2と3を取得します。
今まで動かなかった。
これは非常に簡単なことです(対応するセルラベル間で配列アイテムを分散することだけに問題がある場合)...すべてのセルが2つの配列エントリを「消費」するため-セルの数は[dataArray count] / 2に等しくなります:
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return [dataArray count]/2;
}
次に、cellForRowAtIndexPath実装で:
...
cell.textLabel.text = [dataArray objectAtIndex:2*indexPath.row];
cell.detailTextLabel.text = [dataArray objectAtIndex:2*indexPath.row + 1];
...
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
// the usual cell creation/reuse stuff..
// obtain Label1, 2 by viewWithTag..
// index is your instance variable..
index = indexPath.row * 2;
Label1.text = [myArr objectAtIndex:index];
Label2.text = [myArr objectAtIndex:index + 1];
}