そのため、1 つのビューで 2 つのテーブルビューを作成しようとしていますが、問題が発生しています。それを行う方法について他の回答を読みましたが、正確には役に立ちません。
私の .h ファイルでは、それらmyFirstViewText
を呼び出す 2 つのビュー用に 2 つのアウトレットを作成し、mySecondViewTex
だから私のmファイルでは -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
異なるコントローラーごとに個別の値を出力できるようにしたいのですが、セルが 1 つしか返されないのでよくわかりません。
これまでのところ、私はこれをやった
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *CellIdentifier = @"Rx";
static NSString *CellIdentifier2 = @"allergies";
UITableViewCell *cell = [tableView dequeueReusableHeaderFooterViewWithIdentifier:CellIdentifier];
UITableViewCell *cell2 = [tableView dequeueReusableHeaderFooterViewWithIdentifier:CellIdentifier2];
if(!cell){
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
if (!cell2) {
cell2 = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier2];
}
if (tableView == self.myFirstTextView ) {
cell.textLabel.text = @"HI JAZZY";//[RxDict objectAtIndex:indexPath.row];
}
if (tableView == self.mySecondTextView) {
cell.textLabel.text = @"BYE JAZZY";//[RxDict objectAtIndex:indexPath.row];
}
tableView = self.mySecondTextView;
cell2.textLabel.text = @"I love Jazzy :D";
return cell2;
これにより、最初の TableView に「I love Jazzy」が出力され、2 番目の TableView には何も出力されません。なぜこれが起こり、どうすれば修正できますか? ありがとう