我在一个视图上有两个表,一个是自定义表,另一个是简单表,如何在两个表上显示数据?

时间:2012-12-24 15:02:53

标签: iphone objective-c ipad cocoa-touch ios-simulator

我有两个表视图。

一个很简单,另一个是自定义的。我通过JSON获得价值。我一次发出一个JSON请求,但是当我调用简单表和自定义表的JSON请求时,它会在自定义表上显示数据但突然之后,简单表加载但它隐藏了第一个自定义数据表

有谁知道为什么会这样?

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{

    if (tableView==self.table) {
        return 1;
    }
    else if(tableView==self.clearificationTable){
        return 1;
    }
    return 0;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    if (tableView==self.table) {
        return [reminderArrayList count];
    }
    else if(tableView==self.clearificationTable) {
        return [taskListArray count];
    }
    return 0;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath  *)indexPath{
    if (tableView==self.table) {
        UITableViewCell *cell =[tableView dequeueReusableCellWithIdentifier:@"MyCell"];
        [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
        if (cell == nil){
            cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"MyCell"];
        }
        cell.textLabel.text=[reminderArrayList objectAtIndex:indexPath.row];
        newCell=cell;
     }
     else if (tableView==self.clearificationTable) {
        static NSString *CellIdentifier=@"Cell";
        StaffDahsBoardCustom *cell=[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
        if (cell==nil) {
            [[NSBundle mainBundle]loadNibNamed:@"StaffDahsBoardCustom" owner:self options:nil];
        }
        cell=custom;
        [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
        cell.taskListlbl.text=[taskListArray objectAtIndex:indexPath.row];
        cell.tasktypelbl.text=[tasktypeArray objectAtIndex:indexPath.row];
        cell.completelbl.text=[NSString stringWithFormat:@"%@",[completeArray objectAtIndex:indexPath.row]];
        cell.incompletelbl.text=[NSString stringWithFormat:@"%@",[incompleteArray objectAtIndex:indexPath.row]];
        cell.nalbl.text=[NSString stringWithFormat:@"%@",[NaArray objectAtIndex:indexPath.row]];
        cell.returnlbl.text=[ReturneDateArray objectAtIndex:indexPath.row];
        newCell=cell;        
    }
    return newCell;
}

1 个答案:

答案 0 :(得分:1)

使用表格的标记值。

firstTable.tag=1;

secondTable.tag=2;