2016-08-22 6 views
1

私はObjective Cを初めて使用しており、Expended Table View Cellにイメージを追加できません。 私のコードは次のとおりです。Expended TableViewCellにコンテンツを追加する方法

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{ 

    if ([indexPath compare:self.expandedIndexPath] == NSOrderedSame) { 
     return 200.0; // Expanded height 
    } 
    return 63; 
} 

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

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    [tableView beginUpdates]; // tell the table you're about to start making changes 

    if ([indexPath compare:self.expandedIndexPath] == NSOrderedSame) { 
     self.expandedIndexPath = nil; 
    } else { 
     self.expandedIndexPath = indexPath; 
     // hideview.hidden=NO; 
    } 
    [tableView endUpdates]; // tell the table you're done making your changes 

} 

私は、セルを消費することができますが費やさテーブルビューセルに画像を追加するためできません。

+0

@VinceBowdrenどのような例を教えてもらえますか? – Muju

答えて

0

UIAlertControllerのUITableView.Show UITableViewの代わりにUIAlertControllerを使用することもできます。

ヒアは、UIAlertControllerでUITableViewを表示する方法のコードです。

UIViewController *controller = [[UIViewController alloc]init]; 
    CGRect rect; 
    if (idarray.count < 4) { 
     rect = CGRectMake(0, 0, 272, 160); 
     [controller setPreferredContentSize:rect.size]; 

    } 
    else if (idarray.count < 6){ 
     rect = CGRectMake(0, 0, 272, 300); 
     [controller setPreferredContentSize:rect.size]; 
    } 
    else if (idarray.count < 8){ 
     rect = CGRectMake(0, 0, 272, 200); 
     [controller setPreferredContentSize:rect.size]; 

    } 
    else { 
     rect = CGRectMake(0, 0, 272, 250); 
     [controller setPreferredContentSize:rect.size]; 
    } 

    alert = 
    [UIAlertController alertControllerWithTitle:@"Your Title" 
             message:@"" 
           preferredStyle:UIAlertControllerStyleAlert]; 

    TableName = [[UITableView alloc]initWithFrame:rect]; 
    TableName.delegate = self; 
    TableName.dataSource = self; 
    [controller.view addSubview:TableName]; 
    [controller.view bringSubviewToFront:TableName]; 
    [controller.view setUserInteractionEnabled:YES]; 
    [TableName setUserInteractionEnabled:YES]; 
    [TableName setAllowsSelection:YES]; 

    [alert setValue:controller forKey:@"contentViewController"]; 

    UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { 

    }]; 
    [alert addAction:cancelAction]; 

    [self presentViewController:alert animated:YES completion:nil]; 
関連する問題