表视图选择和更新单元格值的示例 [英] Example of table view selection and updating cell value

查看:72
本文介绍了表视图选择和更新单元格值的示例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个表视图,当用户单击第一个,第二个表视图的一个单元格时出现。但我不知道如何使用第二个中的选定值更新第一个视图控制器。请您分享任何链接或示例吗?

I have two table views, when user clicks one cell of the first, second table view appears. But I don't know how to update first view controller with the selected value in second one. Please, can you share any link or example?

谢谢

推荐答案

你可以像这样区分tableView ...这里我拿两个tableView即tblMain1和tableDetail

You can differentiate the tableView like this...here i take two tableView i.e tblMain1 and tableDetail

 - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    // Return the number of rows in the section.
    if (tableView==tblMain) 
    {
        return [arrOfProfileView count];
    }
    else
    {
        return [arrOfProfileView2 count];
    }
 }

 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:nil];
    if (cell == nil) 
    {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil] autorelease];
    }
    if (tableView==tblMain) 
       {
           //write code here for your mainTable.
       }
       else
       {
           //write code here for your detailTable.
       }

      return cell
 }

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (tableView==tblMain1) 
    {
        //write code here
        [tableDetail reloadData];
    }
    else{
         //write code here
         [tblMain1 reloadData];
    }
}

这篇关于表视图选择和更新单元格值的示例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆