如何在ipad中的一个主视图中提供两个视图?

时间:2012-10-15 07:31:09

标签: ios user-interface

我想在一个主视图中使用两个tableviews。我的应用程序仅在横向模式下运行。左侧是第一个表视图,右侧是第二个表视图。我现在有这两个。

我需要在右侧再调用4个额外的视图。但是这个视图调用应该来自左侧表视图,因为在左侧,显示了视图名称列表。如果我单击任何单元格,右侧视图应显示我单击的视图。

我没有使用splitview,我不想在这个应用程序中使用splitview,所以如何从左侧调用该视图?

1 个答案:

答案 0 :(得分:0)

您可以使用两个表,一个在左侧,第二个在右侧: tableview1.tag = 0; tableview.tag = 2;

在点击左侧表格中的任何一行时,只需重新加载tag = 2的表格视图

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section        {
     if (tableView.tag == 1)
                return 5;
            else if (tableView.tag == 2)
                return 10;
        }


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

            static NSString *identifier = @"CellIdentifier";    
            UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];

            if (cell == nil) {
                cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier] autorelease];

            }
            if (tableView.tag == 1)
            {
        ///// Do whatever you want to do
            }
            else if (tableView.tag == 2)
            {
        ///// Do whatever you want to do
            }
            cell.textLabel.text = @"example";       
            return cell;
        }