Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8510171
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T03:37:58+00:00 2026-06-11T03:37:58+00:00

I have a play button, which when pressed, plays a sound, and then changes

  • 0

I have a play button, which when pressed, plays a sound, and then changes the image to a pause button. The button is a property of my cell which is in my table view.
I’m able to access the cell when the user hits the button because I can do this:

UIButton *b = (UIButton *)sender;
myTableViewCell* cell =  (myTableViewCell*)[[b superview] superview];

And then I can say

[cell.button setImage:myImage];

But I want to change the image of the button back to a play button once the sound is over. I know about the delegate method

-(void)audioPlayerDidFinishPlaying:
(AVAudioPlayer *)player successfully:(BOOL)flag 
{
    NSLog(@"audioPlayerDone");
}

And I do get the NSLog when it is completed, but how could I access the cell and change the image? I don’t have the luxury of calling superview twice as I did before as there is no sender in this delegate method. Any help??

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T03:37:59+00:00Added an answer on June 11, 2026 at 3:37 am

    The table view represents some content (audio), therefore it makes sense you have a model (object) behind each table view cell.

    For each cell you could create an object with 2 or more properties:
    – audiofile: path to a file
    – is playing: boolean value

    The moment an audio file starts playing (button is pressed) you set the boolean value “is playing” to true and you update the table view so a different image is displayed on the button. To figure out which object you need to change state for, use the method -indexPathForCell:. The code will look somewhat like the following for your button press method:

    UIButton *b = (UIButton *)sender;
    myTableViewCell* cell =  (myTableViewCell*)[[b superview] superview];
    
    NSIndexPath *indexPath = [tableView indexPathForCell:cell];
    AudioObject *audio = [dataArray objectAtIndex:indexPath.row];
    audio.isPlaying = true;
    
    [tableView reloadData];
    

    The moment the audio file stops playing you can check the array with models for any file that is playing and set it to false. Afterwards you update the table view again so the button image changes back to the default one.

    An implementation like the one I described above will work fine if only 1 audio file is playing at any time.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I have a Player view with seekbar and play/pause/rewind, etc. buttons, which are
I have an image with a play/pause button positioned absolute and centered over top.
Ok, I have a button that, when pressed, should animate/play a png image sequence.
I have a play, pause button which controlled by JQuery, when I click play
I am developing a soundboard application which extends ListActivity. I have a play button
I have an application which will support several standard operations play stop pause undo
I have a function playsounds() which basically plays the same sound file again and
A player: http://www.yvoschaap.com/videowall/ How can you customise the above Chromeless Youtube to have Play/Stop/Pause
I have MyActivity and MyService (which plays music). I have also notification (in Notifications
I have a music player activity with a service which plays the music. When

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.