2

「+」ボタンをクリックしたときにセルを展開し、その中に画像とビデオを追加したいテーブルを作成しました。時々、特定のセルの高さを上げてからビデオを表示する必要があり、「+」記号は「-」に変換されます。

ここに画像の説明を入力してください

今、私は次のようにセルを展開するコードを追加しました

-(void)cellButtonOneSelected
{
    // Deselect cell
[safetChecklistsTableView deselectRowAtIndexPath:selectedIndexPath1 animated:TRUE];

// Toggle 'selected' state
BOOL isSelected = ![self cellIsSelected:selectedIndexPath1];

// Store cell 'selected' state keyed on indexPath
NSNumber *selectedIndex = [NSNumber numberWithBool:isSelected];
[selectedIndexes setObject:selectedIndex forKey:selectedIndexPath1];    

// This is where magic happens...
[safetChecklistsTableView beginUpdates];
[safetChecklistsTableView endUpdates];
}

では、その中にビデオや画像を表示/追加するにはどうすればよいですか?

4

2 に答える 2

0

ビデオと画像をuiviewに入れて、セルの高さが50の場合のようにセルに追加し、51に追加します。

yourView.hidden=YES; 
yourView.tag=@"your Tag"

この追加ボタンが押されたら、次のループを呼び出します。

for (int section = 0, sectionCount = _iTableView.numberOfSections; section < sectionCount; ++section) {
        for (int row = 0, rowCount = [_iTableView numberOfRowsInSection:section]; row < rowCount; ++row) {
            UITableViewCell *cell = [_iTableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:row inSection:section]];
            UIView *view=(UIView*)[cell.contentView viewWithTag:@"Your Tag"];
            view.hidden=NO;
        }
    }

お役に立てれば!!

于 2012-07-30T09:06:31.263 に答える
0

セルに次のコードを追加します'cellForRowAtIndexPath:'

 if([self cellIsSelected:indexPath])
    {
        [cellButton setImage:[UIImage imageNamed:plusImageName] forState:UIControlStateNormal];
        cellSubLabel.text=@"Close";

      if (indexPath==selectedIndexPath) {
        UIImageView *imageView=[[UIImageView alloc] initWithImage:[UIImage imageNamed:imageName]];
        imageView.frame = (CGRect){170,80,130,80};
        [tableCell addSubview:imageView];
     }
   }
    else
    {
        [cellButton setImage:[UIImage imageNamed:minusImageName] forState:UIControlStateNormal]; 
    }
于 2012-07-30T11:34:21.597 に答える