TableViewCell Button Sound

Discussion in 'iPhone/iPad Programming' started by freshking, Feb 25, 2009.

  1. macrumors newbie

    Joined:
    Feb 15, 2009
    #1
    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

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #2
    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

    Joined:
    Sep 17, 2003
    #3
    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