Note that there are some explanatory texts on larger screens.

plurals
  1. POPassing data into Container View using Embed Segue
    primarykey
    data
    text
    <p>So I've seen most of the tutorials (and am using the technique) to pass data from one view controller to the next when the segue is a push (in the prepareForSegue method). I can cast the <code>destinationViewController</code> to my custom class and push data into custom properties.</p> <p>However, when I try to do this for an Embed Segue (the new one in iOS6 which allows Container Views to work), the destinationViewController doesn't seem to be right; it's just a UIViewController, not the custom class I have defined in the storyboard.</p> <p><img src="https://i.stack.imgur.com/5sEUz.png" alt="Storyboard Example"></p> <p>As you can see, I have my main table view with Start and End dates. I then have a subview, embedded using the Container View. This has a toolbar for command dates + a UIDatePicker.</p> <p>My issue is that I need the main table view controller to have an event listener from the Date Picker (the <code>UIControlEventValueChanged</code> one, to update the labels). The parent controller can't see the date picker. Both View Controllers have custom classes implemented. The Date Picker controller class has the date picker as an IBOutlet object and the 3 date range buttons have selected methods which do change the date.</p> <p>It seems my issue here is context between the two view controllers.</p> <p>FYI: I need them separate so I can toggle the visibility of the date picker widget &amp; toolbar.</p> <h3>UPDATE 1:</h3> <p>I have found a work around, which is on the prepare segue at parent level, pass a "self" reference to the child which has a property of the parent view controller type. This gives the child a proper reference to its parent, which I can then do the following with:</p> <pre><code>-(void) viewDidLoad { [[self datePicker] addTarget:[self graphSettingsViewController] action:@selector(datePickerValueChanged:) forControlEvents:UIControlEventValueChanged]; } </code></pre> <p>This works but feels "messy". Any ideas?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload