How do I detect which push segue initiated a view controller?

Discussion in 'iOS Programming' started by moonman239, Sep 23, 2013.

  1. moonman239 macrumors 68000

    Joined:
    Mar 27, 2009
    #1
    I have a view controller. In this view controller is content that appears in an orderly fashion. I also have a table view controller. Each cell in the table view is supposed to cause the other view controller to display a specific portion of the controller.

    Is it possible to do this? If so, how? Also, would creating separate view controllers and programming my app to initiate one view controller after the preceding one's content has been displayed be a better idea?
     
  2. ArtOfWarfare macrumors 604

    ArtOfWarfare

    Joined:
    Nov 26, 2007
    #2
    UIViewController has a method called prepareForSegue:sender: that I think you'll find is useful. You can determine who is triggering the segue using the sender argument as well as the view controller being segued to by checking the destinationViewController property of the segue argument.
     
  3. moonman239 thread starter macrumors 68000

    Joined:
    Mar 27, 2009
    #3
    Thanks. I just tried creating a separate view controller and just programming my app to jump to that view controller when the first one's controller finished, but got an error. I think I'll just use the prepareForSegue method. Thankfully, I have a snapshot I can restore my project to.
     

Share This Page