Objective c 使用2表视图

Objective c 使用2表视图,objective-c,uitableview,Objective C,Uitableview,大家好,请问我如何使用2 TableView,我使用这个代码,但我的问题是我的Cellle同名 - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { // Return the number of sections. return 1; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsI

大家好,请问我如何使用2 TableView,我使用这个代码,但我的问题是我的Cellle同名

 - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
        // Return the number of sections.
        return 1;
    }


    - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
       if (choix==1) {
            NSLog(@"%d",choix);
           return [mutable3 count]; 

       }
        else {
                NSLog(@"%d",choix);
            return [mutable2 count];    
        }
    }


    // Customize the appearance of table view cells.
    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
        if (choix==1) {
            NSLog(@"cc%d",choix);
            static NSString *CellIdentifier = @"Cell";

            UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
            if (cell == nil) {
                cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
            }
            cell.textLabel.text = [mutable3 objectAtIndex:indexPath.row];

            // Configure the cell...

            return cell;

        }
        else {
            NSLog(@"vvv%d",choix);

            static NSString *CellIdentifier = @"Cell";

            UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
            if (cell == nil) {
                cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
            }
            cell.textLabel.text = [mutable2 objectAtIndex:indexPath.row];

            // Configure the cell...

            return cell;
        }
    }   
    #pragma mark -
    #pragma mark Table view delegate

    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
        if (choix==1) {

                NSLog(@"%d",choix);


        langue.text  =[mutable3 objectAtIndex:indexPath.row];   

            langView.hidden=TRUE;
        }
        else {

                NSLog(@"%d",choix);
            compain.text =[mutable2 objectAtIndex:indexPath.row];   

            langView.hidden=TRUE;
        }
   }

好的,这将是一个简单的解释,希望你能理解。如果你不知道,请询问,我会详细说明

TableView取消公差示例:

UITableView tableView1;
UITableView tableView2;
每个tableview都有一个变量名,它链接到的变量名不同。因为我们使用的是指针,所以它允许我们在委托方法中执行以下操作(所有这些方法,这只是一个示例)

委托方法示例:

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    if (tableView== tableView1)
    {
         return 2;
    }
    else if(tableView== tableView2)  //this if statement is not really needed since if you only have 2 table views the second will automatically fall into the else
    {                           
        return 3;
    }
    else  //This else is only needed if you use the second if statement
        return 0;
}

你可以对所有delagate方法使用相同的方法

你到底想做什么?我想在同一个视图中使用2个UITableView我在文本文件中clid时有2个UITextField我显示我的表格视图如果我在其他文本文件中单击,我会显示其他tableviewD'abord,pouvez vou nous dire le sens de«choix»?你是克莱尔吗?你是蒙特勒吗?Montrez le en dessus,dans votre问题首字母缩写,avec le Format,SvPausi,vous devez augmenter votre taux d’acceptation,si vous voulez que les gens faire des réponses.-(UITableViewCell*)tableView:(UITableView*)tableView Cell for Rowatindexpath:(NSIndexPath*)indexPath{我在2 tableview中的单元格有相同的名称。您在2 tableview中的单元格有相同的名称是什么意思?因为您可以使用NSIndexPath访问这些单元格?那么为什么该单元格有名称?您有什么问题?因为choix的默认值不同于1,所以ferst tableview中的单元格等于e其他tqbleview