gpt4 book ai didi

ios - 如何在一个 View Controller 中为 TableView 分配标签值

转载 作者:行者123 更新时间:2023-11-29 00:18:50 25 4
gpt4 key购买 nike

我必须在一个 View Controller 中调用两个 TableView 。我已经为第一个 TableView 分配了标记值,我只获取一个 TableView 的数据,其他 TableView 没有显示任何数据。如何获取两个 TableView 的数据.

我已经分配了 firsttableview.tag=1

    (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
if(tableView.tag==1){
FirstTableViewCell *cell1=[tableView dequeueReusableCellWithIdentifier:@"ProfileTableViewCell"];

if(!cell1){
cell1=[[FirstTableViewCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"FirstTableViewCell"];
}
cell1.backgroundColor=[UIColor clearColor];
cell1.dateLbl.text=@"ios";
cell1.timeLbl.text=@"9:30AM";
//[self.secondTableView reloadData];
return cell1;

}
SecondTableViewCell *cell1=[tableView dequeueReusableCellWithIdentifier:@"SecondTableViewCell"];

if(!cell1){
cell1=[[SecondTableViewCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"SecondTableViewCell"];
}
cell1.backgroundColor=[UIColor clearColor];
cell1.locationLbl.text=@"Hyderabad";
return cell1;
}
}

最佳答案

使用像 `-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 这样的对象检查 tableview {

if ([tableView isEqual: table1]) {

UITableViewCell *cell1 = [[UITbaleViewCell alloc] init];

return cell1

否则如果([tableView isEqual: table2]){

 UITableViewCell *cell2 = [[UITbaleViewCell alloc] init];

return cell2

}

}`

关于ios - 如何在一个 View Controller 中为 TableView 分配标签值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44559877/

25 4 0