2016-08-23 4 views
0

私は次のように細胞内にのtableViewを示したい:どのように客観的なCのCellViewにtableViewを追加するには?

_____________________________________ 
| (IMAGE) ______________    | --CELL 0 

|   | MyCustomText|--CELL 0.0 | 
|   |_____________|    | 
|   |MyCustomText2|--CELL 0.1 | 
|   |_____________|    | 
|          | 
|          | 
    -------------------------------------- 
    _____________________________________ 
| (IMAGE) 2       | --CELL 1 
    -------------------------------------- 

私はストーリーボードでのtableViewを追加し、新しいTableviewControllerとし、新しいCustomCellTableViewに接続しようとしているが、これは列のテーブルには何も表示されません。

可能でしょうか? viewControllerを宣言するか、ViewControllerを追加する必要はありませんか?

ありがとうございます!

+0

あなたはCELL0の内容をスクロールすることを必要があります適切な説明を与えるだろう、この答えを確認してください(のtableViewの残りwitouthスクロールしますか)?そうでない場合、 'UITableView'は異なるタイプのセルを管理できます。 2つのカスタムセルを持つことができます.1つはcell0用、もう1つはcelle1用です。 – Larme

+0

質問が少しクリアしてサンプル画像を追加する必要があります – Spynet

+0

可能な複製[UITableViewCell内でUITableViewを追加することは可能ですか](http://stackoverflow.com/questions/17398058/is-it-possible-to-add -uitable-within-a-uitableviewcell) – Sandy

答えて

0

新しいテーブルビューコントローラは必要ありません。テーブルセルでは、別のテーブルビューを追加できます。

@interface ImageCell : UITableViewCell<UITableViewDataSource,UITableViewDelegate> 

@property (retain, nonatomic) IBOutlet UITableView *abc; 

@end 

通常の方法でデータソースとデリゲートメソッドを実装します。

#pragma mark - Table view data source 

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { 
    return 1; 
} 

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 
    return 1; 
} 

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:<#@"reuseIdentifier"#> forIndexPath:indexPath]; 

    // Configure the cell... 

    return cell; 
} 
0
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ 
    if (tableView == self.tableView) { 
     return 8; 
    } else { 
     return 3; 
    } 
} 

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 
    UITableViewCell *cell; 
    if (tableView == self.tableView) { 
     cell = [self.tableView dequeueReusableCellWithIdentifier:@"cell"]; 
     if (cell == nil) { 
      cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"]; 
     } 
     if (indexPath.row == 0) { 
      self.childTableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 64, self.view.bounds.size.width, 100)]; 
      self.childTableView.delegate = self; 
      self.childTableView.dataSource = self; 
      [cell.contentView addSubview:self.childTableView]; 
     }else { 
      cell.textLabel.text = @"Pavan"; 
     } 
    } else if (tableView == self.childTableView){ 
     cell = [self.tableView dequeueReusableCellWithIdentifier:@"childCell"]; 
     if (cell == nil) { 
      cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"childCell"]; 
     } 
     cell.textLabel.text = @"hi"; 
    } 
    return cell; 
} 

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { 
    if (tableView == self.tableView) { 
     if (indexPath.row == 0) { 
      return 250; 
     } else { 
      return 100; 
     } 
    } else { 
     return 50; 
    } 
} 
関連する問題