TableViewCell Button Sound

Discussion in 'iOS Programming' started by freshking, Feb 25, 2009.

  1. macrumors newbie

    Feb 15, 2009
    Hi all,

    I have a custom tableView in which each cell contains a UIButton. When I press the button of any cell I want to play a system sound for that particular cell.
    (I set up the custom cell in a UITableViewCell subclass (NumbersDetailCell) )

    The problem is that the sound plays as soon as the tableView loads and not when I press the button in the cell. Nothing happens when I press the button.
    Its probably a stupid mistake but I just can't seem to figure it out. So any help is well appreciated!
  2. Moderator


    Staff Member

    Sep 2, 2004
    The Centennial State
    Move the audio playing logic out of the tableView:cellForRowAtIndexPath: method (which is part of the UITableViewDataSource protocol, used for populating the content of the table view) and put it in a tableView:didSelectRowAtIndexPath: method (which is part of the UITableViewDelegate protocol, used for handling actions for the table view).
  3. macrumors 6502

    Sep 17, 2003
    Remember to unselect the row after you select it though or Apple will rejected you based on this clause from HI Guidelines:

    "Table views provide feedback when users select list items. Specifically, when an item can be selected, the row containing the item highlights briefly when a user selects it to show that the selection has been received. Then, an immediate action occurs: Either a new view is revealed or the row displays a checkmark to indicate that the item has been selected. The row never remains highlighted, because table views do not display persistent selected state."

Share This Page