从另一个控制一个UITable

时间:2011-11-17 06:37:10

标签: iphone objective-c ios uitableview

我正在构建一个简单的iOS应用,其中包含两个UITableViewController个用于创建日期导航(ScrollingDateViewController)的水平表和第二个UITableView (LogItemsTableViewController)显示所选日期的已记录项目。

在我的viewDidLoad方法中,我有以下内容:

NSLog(@"show scrolling date selector");
scrollingDateViewController=[[ScrollingDateViewController alloc] initWithNibName:@"ScrollingDateView" bundle:[NSBundle mainBundle]];
CGRect rect=CGRectMake(0,330,320,100);    
scrollingDateViewController.view.frame=rect;
scrollingDateViewController.view.backgroundColor=[UIColor clearColor];
scrollingDateViewController.delegate = self;
[self.view addSubview:scrollingDateViewController.view];

NSLog(@"show log item selector");
logItemsTableViewController=[[LogItemsTableViewController alloc] initWithNibName:@"LogItemsView" bundle:[NSBundle mainBundle]];
rect=CGRectMake(0,0,320,330);    
logItemsTableViewController.view.frame=rect;
logItemsTableViewController.view.backgroundColor=[UIColor clearColor];
[self.view addSubview:logItemsTableViewController.view];

[super viewDidLoad];

所有这两个表似乎都运行良好。我现在遇到的问题是如何在滚动日期表中选择新日期时控制日志项目表。我怀疑答案很简单,但我是iOS编程的新手,只是在解决这些问题。我很感激任何帮助。

1 个答案:

答案 0 :(得分:5)

您需要实现此功能

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath

代表ScrollingDateViewController。现在,在此功能中,您必须实现有关更改LogItemsTableViewController的想法。为此,您必须访问UITableView LogItemsTableViewController ScrollingDateViewController。{/ p>

我希望它对你有用!