2012-10-15 48 views
0

我想在一個主視圖中使用兩個tableviews。我的應用程序只能在橫向模式下運行。左邊是第一個tableview,右邊是第二個table view。我現在有這兩個。如何在ipad中的一個主視圖中給出兩個視圖?

我需要在右側調用4個額外的視圖。但是這個視圖調用應該來自左側表格視圖,因爲在左側,視圖名稱列表被顯示。如果我點擊任何單元格,則右側視圖應顯示我點擊的視圖。

我沒有使用splitview,我不想在這個應用程序中使用分割視圖,所以我怎樣才能從左側調用該視圖?

回答

0

您可以使用兩個表,一個在左側,另一個在右側: tableview1.tag = 0; tableview.tag = 2;

只需重新裝入標籤= 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; 
     } 
相關問題