2017-02-10 8 views
0

子セルをUITableViewCell内に表示しようとしています。グループ名とグループIDを含む2つの配列があります。次のコードを使用して、カスタムTableViewCellでtableviewにgroupnameを表示できます。 TableViewCellユーザーをユーザーがクリックすると以下のように選択したグループIDに関連する製品のリストを見ることができると彼は製品を選択することができますサブセルをUITableViewCell内に表示

NSArray *groupIdArr; 
    NSArray *groupNameArr; 

groupNameArr (
    ANTISERA, 
    CLIA, 
    COAGULATION, 
    CONFIRMATORY, 
    ELISA, 
    IMMUNOLOGY, 
    MISC, 
    RAPID 
) 

groupIdArr (
    20, 
    21, 
    22, 
    23, 
    19, 
    31, 
    29, 
    18 
) 


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 
{ 
    return [groupIdArr count]; 
} 



- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    static NSString *simpleTableIdentifier = @"ProductGroupTableViewCell"; 

    ProductGroupTableViewCell *cell = (ProductGroupTableViewCell *)[tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier]; 
    if (cell == nil) 
    { 
     NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"ProductGroupTableViewCell" owner:self options:nil]; 
     cell = [nib objectAtIndex:0]; 
    } 

    cell.productGroupNameLbl.text = [groupNameArr objectAtIndex:indexPath.row]; 

    return cell; 
} 

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
     NSString *saveGroupId = [groupIdArr objectAtIndex:indexPath.row]; 

     [[NSUserDefaults standardUserDefaults] setObject:saveGroupId forKey:@"SavedGroupId"]; 
     [[NSUserDefaults standardUserDefaults] synchronize]; 

    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil]; 
    UIViewController *productListVC = [storyboard instantiateViewControllerWithIdentifier:@"ProductsListViewController"]; 
    [self.navigationController pushViewController:productListVC animated:YES]; 


} 

enter image description here

。製品のユーザーを選択した後

enter image description here

は、彼がグループ名に以下の選択した製品を見ることができる前のビューに戻るために行わボタンを押します。 NSMutableArrayで選択した製品名を前のビューに表示しています。しかし、私は下の出力を表示する方法を理解することができません。

私は解決策を見つけるのに多くの努力をしましたが、運はありませんでした。どんな助けでも本当に感謝します。

enter image description here

答えて

0

あなたは、セル内のサブセルを示すためのUIViewを使用することができます。プログラムでUIViewを作成します。セル内にこのビューを追加し、必要なときにいつでもそのセルをリロードし、必要な高さに応じて高さを変更してください。

0

このデモを確認してください。解決策が見つかります。

SideMenu Demo

+0

これをダウンロードして、ビットコードを変更する必要があります。そしてあなたはあなたの欲望の結果を得ました。ちょうどあなたのためのデモを開発しました。何か助けが必要なら私に知らせてください。 – PSS

関連する問題