UITable 'Edit' as shift key?

Discussion in 'iOS Programming' started by stephanos180, Dec 16, 2010.

  1. stephanos180 macrumors member

    Joined:
    Aug 23, 2006
    Location:
    Downey, CA
    #1
    Hello, everyone. I'm trying to make a navigation-based app. So far, I'm just working on my 'home screen' and figured out how to transition based on selecting a row in a UITableView. Is there a way to use an 'Edit' button to transition to a different window once it has been pressed and a row selected? Thanks in advance.
     
  2. cnstoll macrumors 6502

    Joined:
    Aug 29, 2010
    #2
    Sure. In your UITableViewController class implementation you can override the setEditing method, which gets called when the edit button is tapped.

    In that method you could do something like changing the tableView's "allowsSelection" property to YES/NO based on if your table is being edited or not.

    Doing that would mean a user would have to tap edit first to allow tapping a table row to be selected, and thus transfer to a new view if that's how your row selection method is defined.
     
  3. stephanos180 thread starter macrumors member

    Joined:
    Aug 23, 2006
    Location:
    Downey, CA
    #3
    Thanks for your reply. Wouldn't that only let me do edit+press or just press, but not both?
     
  4. cnstoll macrumors 6502

    Joined:
    Aug 29, 2010
    #4
    That would only let you do edit + press.

    Are you trying to make it so that press works one way, but that edit + press works a different way?
     
  5. stephanos180 thread starter macrumors member

    Joined:
    Aug 23, 2006
    Location:
    Downey, CA
    #5
    Exactly. Thanks, again.
     
  6. cnstoll, Dec 16, 2010
    Last edited: Dec 16, 2010

    cnstoll macrumors 6502

    Joined:
    Aug 29, 2010
    #6
    Ok, that's even easier.

    The UITableView has an editing property that will tell you if your table is in edit mode or not.

    Just check that property in your didSelectRowAtIndexPath: method and design your logic accordingly so that if that's YES (shift) it does one thing, and if NO do the other thing.
     

Share This Page