Note that there are some explanatory texts on larger screens.

plurals
  1. POGetting a the current instance of the "Parent" view controller
    primarykey
    data
    text
    <p>i have a embeded view, inside another view, how would i get the current instance of the parents viewController in the Childs viewController, need it to call a method on the parent, on the current instance.</p> <p>This is how i current call the method on the parent, this allocates a new instance.</p> <pre><code>CalendarMonthViewParent *controller = [[CalendarMonthViewParent alloc] init]; [controller callChildChange]; </code></pre> <p>I get "No visible interface declares "callChildChange", if i call it like this:</p> <pre><code>[self.parentViewController callChildChange]; </code></pre> <p><strong>EDIT 1:</strong> </p> <p>CalendarMonthViewParent.h</p> <pre><code>#import &lt;UIKit/UIKit.h&gt; @interface CalendarMonthViewParent : UIViewController -(void) callChildChange; @property (strong, nonatomic) IBOutlet UINavigationItem *skemaNavigationItem; @end </code></pre> <p>CalendarMonthViewParent.m</p> <pre><code>- (void)callChildChange { // this is called from the child UINavigationItem *navBar = [self skemaNavigationItem]; NSLog(@"logging navItem: %@", navBar); // this logs null when called from the child, since its called on a new instance and not the old one, if i call this from the parent directly, it is not null } </code></pre> <p>CalendarMonthViewChild.m</p> <pre><code>- (void) calendarMonthView:(TKCalendarMonthView*)monthView didSelectDate:(NSDate*)date{ NSLog(@"Date Selected: %@",date); ... CalendarMonthViewParent *controller = [[CalendarMonthViewParent alloc] init]; [controller callChildChange]; // this calls it on a new instance, i need it to call it on the existing instance ... } </code></pre>
    singulars
    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