开发者

TableViewCell, dynamically show Media Player controls iPhone

I am currently developing a app which records some audio files. 开发者_JAVA技巧The audio files are stored locally and the path is stored in core data.

I am populating a TableView with the list of Audio's recorded. When I click a tableviewcell, I am able to play the recorded voice.

I want to show some controls on the table view (like play and pause button same as voice recorder app in iPhone) which will be shown only when the user selects the table cell and will be disappeared when he selects other cell.


If you implement UITableViewCell you'll be able to custom the cell to your own liking. You can also use the method setSelected:( BOOL)selected animated:(BOOL)animated to change the cell depending on wether it is (or isn't) selected.


Write the code to create a custom UITableViewCell(dynamically). You will not get the issue.

Try to use following sample code;

static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
    cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil] autorelease];
}
UIImageView *cellImageView1=[[UIImageView alloc]initWithFrame:CGRectMake(0,0,320,80)];
UIImage *cellImage1=[UIImage imageNamed:@"table_bar.png"];
cellImageView1.image=cellImage1;
cell.backgroundView=cellImageView1;
NSString *projectName = [projectNameArray objectAtIndex:indexPath.row];
cell.imageView.image=[self returnImage:projectName];
cell.imageView.frame=CGRectMake(10, 05, 40, 40);
cell.imageView.image=[self returnImage:projectName];
UILabel *cellLabel=[[UILabel alloc] initWithFrame:CGRectMake(75, 15, 150, 30)];
cellLabel.text=projectName;
cellLabel.backgroundColor=[UIColor clearColor];
cellLabel.textAlignment = UITextAlignmentLeft;
cellLabel.tag = 4444;
[cell.contentView addSubview:cellLabel];
[cellLabel release];
cell.accessoryView =(UIButton*) [buttonArray objectAtIndex:indexPath.row];
return cell;

I hope it will help you.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜