TableView with multiple actions?

Discussion in 'iOS Programming' started by ataylor2009, Mar 16, 2010.

  1. ataylor2009 macrumors member

    Joined:
    Jan 27, 2009
    #1
    Is it possible to have a table view that fires one action when the label is tapped, and a different action when the detail disclosure button is tapped? I'd like to perform a task when the user taps the table row, but I'd like to navigate to a subview if the detail chevron is tapped.

    Thanks in advance for a nudge in the right direction.
     
  2. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #2
    Yes, it's possible. In fact, that's exactly how the cell selection vs. accessory button tapped is designed to work. See the UITableViewDelegate Protocol Reference as well as the "Table View Programming Guide for iPhone OS" for more info.
     
  3. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #3
    As is clearly stated in the documentation tableView:accessoryButtonTappedForRowWithIndexPath will be sent when the accessoryType is UITableViewCellAccessoryDetailDisclosureButton. If the accessoryType is UITableViewCellAccessoryDisclosureIndicator then this won't happen.

    If you need the display of UITableViewCellAccessoryDisclosureIndicator but want to track clicks on the accessory view define a custom UIControl (not UIView) subclass that draws the view you want and have it send the action you want.
     
  4. ataylor2009 thread starter macrumors member

    Joined:
    Jan 27, 2009
    #4
    (Sheepishly...) Sorry folks. I should've looked harder before asking. I was trying to fire off a quick post while I was on break and didn't have access to the documentation.

    Thanks for the assist.
     
  5. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #5
    Apology accepted. Just don't let it happen again. ;)

    All the documentation available in Xcode is also available online. :)
     

Share This Page