Connecting row clicks to viewcontrollers

Discussion in 'iOS Programming' started by akaash1087, Jun 28, 2012.

  1. akaash1087 macrumors newbie

    Jul 7, 2010
    I am a newbie in IOS.I am trying to design a Splitview app which consists of a master and detailsview controller.My master is a table view .My master view controller is called Rootviewcontroller.I create a UINavigationcontroller object and embed the Rootviewcontroller inside it.
    Now I have a navigation controller with my master view controller(Rootviewcontroller) as its rootviewcontroller.
    What I want is that on a row click on the masterview controller an appropriate VC should get launched.For that I have read the Apple documentation(Managing Selections in Tableview programming) and have implemented it the way it is given:

    I override the didSelectRowAtIndexPath method.Inside it I deselect the earlier selected row,create a VC and then push it onto the navigation stack using the Push API.But it does not work..

    Do we need to first create our own VC and then push that VC on the navigation stack? Or is it that only the detailviewcontroller can be pushed.
    And if thats the case,then how do we display different views for different rows??..Logically speaking shouldnt there be more than one detailVCs with different ones getting launched on different row clicks..??

    I have detailed the steps above ,have I missed out anything??Do I need to pop some VC or something like that..

    Any help would be highly appreciated....
  2. jnoxx macrumors 65816


    Dec 29, 2010
    Aartselaar // Antwerp // Belgium
    What have you tried to debug, because "it doesn't work", isn't really helpfull.

    Basically, you need to know if your controller is a single view, or is in a navigationController? if it is, then what goes wrong, is your new ViewController nil or does it exist? did you try setting breakpoints etc?

  3. MattInOz macrumors 68030


    Jan 19, 2006
    This maybe a wild stab in the dark.
    Your project is for the iPad?
    Assuming it is as you mention Split View, then again the pushing of a new ViewController on to the Navigation stack sounds more like what you'd do in an iPhone project.

    Did you use the xCode Master/Detail template to start with or did you cook it up based on a simpler template?
    If the later are you following some guide or tutorial to do so?
  4. akaash1087 thread starter macrumors newbie

    Jul 7, 2010
    Splitview controller view not getting launched properly..

    Actually splitview works only on an Ipad.I am using the xcode's master detail template .On some experimentation I have managed to get a view launched but what happens is that when I click on a particular row the new view comes over the rootviewcontroller view(master view) which is not what I want.I want the new view to get launched on the detail view.The rootviewcontroller(master view) is the rootviewcontroller of the navigation controller that I am using.Then in the rootviewcontroller class I access this navigation controler and call pushviewcontroller method to push a viewcontroller (view that I want to display on a row click)on my nav stack .But this displays the view over my master view.Can anybody explain
    where the problem is coming..
    I have read Multiple Detail View app available on apple documentation.It nowhere calls pushviewcontroller method . Would anybody please throw some light on that??
  5. akaash1087 thread starter macrumors newbie

    Jul 7, 2010

    I did some research and found a project on net which had been done on Xcode where the author had created the project by chosing the Spliviewbased application template following which a project got created .It had some code already in it.This code did the job of presenting to you the basic splitview interface with a tableview on the left along with the title and a detail view on the right.In the already written code I noticed that Detailviewcontroller had been made a property of the Rootviewcontroller .Inside the didselectrowat indexpath function ,some detailItem gets set and that gets passed on to Detailviewcontroller.
    My question is even If I work on this line how do I get a different view launched for different row clicks.?
    I have views consisting of various components and different views should get launched on different row clicks.
    What should I pass from Rootviewcontroller to Detailviewcontroller.?What value should I set detailItem to?

    Any help would be most appreciated..

Share This Page