2010-08-02 81 views

回答

1

做到这一点的一种方法是从File-> Add添加两个UITableViewController类到你的项目,然后点击Include Xib选项。这将创建两个表视图xib文件。然后,您可以初始化两个控制器,而在你的主控制器的viewDidLoad事件,并将它们分配一个帧等于左&右视图你有如下:

[firstTableController.view setFrame:rightView.frame]; 
[secondTableController.view setFrame:leftView.frame]; 

如果双方rightView & leftView是UIView的*对象在IB中与您的两个观点相关联。

然后,您可以简单地在两个表控制器从主控制器添加到您的主视图控制器使用addSubView:

[self.view addSubView:firstTableController.view]; 
[self.view addSubView:secondTableController.view]; 

希望这有助于。

+0

这就是天才。非常感谢。 – 2010-08-02 18:04:22

0
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 

{

int x; 
if (tableView.tag == 100) 
{ 
    x = [tab1 count]; 
} 


    if (tableView.tag == 101) 


{ 
    x = [tab2 count]; 
} 
return x; 

} 

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

static NSString *cellIdentifier = @"Helllo"; 


UITableViewCell *cell = (UITableViewCell *)[tableView dequeueReusableCellWithIdentifier:cellIdentifier]; 
if (cell == nil) 
{ 

    cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellIdentifier]; 
} 





if (tableView.tag ==100) 
{ 
    cell.textLabel.text= [tab1 objectAtIndex:indexPath.row]; 
} 
if (tableView.tag == 101) 
{ 
    cell.textLabel.text=[tab2 objectAtIndex:indexPath.row]; 
} 


cell.selectionStyle = UITableViewCellSelectionStyleGray; 
cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton; 


return cell; 

}

TAB1和tab2是数组。