Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to call an action in RootViewController from embedded table view?
    text
    copied!<p>I have a storyboard app with an embedded table view in a container on the root view controller. The user will make some choices on via popups in the embedded table view. When all the choices are made I want a NEXT button in the view of the root view controller to be activated (un dimmed) so the user can touch it.</p> <p>I put an action in the RootViewController when I can do this work - check to see if all values are filed in and undid the button if they are, dim it if they are note. But how can I call that action? I have delegates that get fired whenever the user makes a selection, so it seems his is where I would call that action, but it is not available. </p> <p>Any help would be greatly appreciated.</p> <p>Bryan</p> <p>Here is some code:</p> <pre><code>#import &lt;UIKit/UIKit.h&gt; //#import "popViewController.h" #import "pvcProteinIntendedFor.h" #import "pvcProteinNotOriginateFrom.h" #import "pvcProteinTaste.h" #import "pvcProteinPrice.h" #import "userInputs.h" @interface embeddedTableViewController : UITableViewController &lt;UITableViewDataSource,UITableViewDelegate,pvcProteinIntendedForDelegate,pvcProteinTasteDelegate,pvcProteinPriceDelegate,pvcProteinNotOriginateFromDelegate&gt; @property(strong, nonatomic) UIButton *test; @property(nonatomic, strong) UIButton *parentNextButton; //Buttons for pop @property (weak, nonatomic) IBOutlet UIButton *btnProteinIntendedFor; @property (weak, nonatomic) IBOutlet UIButton *btnProteinNotOriginateFrom; @property (weak, nonatomic) IBOutlet UIButton *btnProteinTaste; @property (weak, nonatomic) IBOutlet UIButton *btnProteinPrice; //Propert for the current PopPover - this will change to one popover //@property (strong, nonatomic) popViewController* currentPopoverController; @property (strong, nonatomic) UIStoryboardPopoverSegue *segPopViewController; //The button action //This is to keep track of which button we came from //@property (weak, nonatomic) IBOutlet UIButton* currentButton; // Access Protein Intended For @property (strong, nonatomic) UIStoryboardPopoverSegue *pvcSegueProteinIntendedFor; @property (strong, nonatomic) pvcProteinIntendedFor *pvcProteinIntendedFor; // Access Protein Not Orignate From @property (strong, nonatomic) UIStoryboardPopoverSegue *pvcSegueProteinNotOriginateFrom; @property (strong, nonatomic) pvcProteinNotOriginateFrom *pvcProteinNotOriginateFrom; // Access Protein Taste @property (strong, nonatomic) UIStoryboardPopoverSegue *pvcSegueProteinTaste; @property (strong, nonatomic) pvcProteinTaste *pvcProteinTaste; // Access Protein Price @property (strong, nonatomic) UIStoryboardPopoverSegue *pvcSegueProteinPrice; @property (strong, nonatomic) pvcProteinPrice *pvcProteinPrice; @end </code></pre> <p>Here is the implementation file:</p> <pre><code>#import "embeddedTableViewController.h" //#import "popViewController.h" #import "pvcProteinIntendedFor.h" #import "pvcProteinNotOriginateFrom.h" #import "pvcProteinTaste.h" #import "pvcProteinPrice.h" #import "userInputs.h" #import "myDataController.h" @interface embeddedTableViewController () //@property(nonatomic, strong) UIButton *parentNextButton; @end @implementation embeddedTableViewController - (id)initWithStyle:(UITableViewStyle)style { self = [super initWithStyle:style]; if (self) { // Custom initialization } return self; } - (void)viewDidLoad { [super viewDidLoad]; } - (void)viewDidAppear:(BOOL)animated { //For Testing [self.btnProteinIntendedFor setTitle:@"Bakery" forState:UIControlStateNormal]; [self.btnProteinNotOriginateFrom setTitle:@"China" forState:UIControlStateNormal]; [self.btnProteinPrice setTitle:@"Extremely Important" forState:UIControlStateNormal]; [self.btnProteinTaste setTitle:@"Somewhat Important" forState:UIControlStateNormal]; myDataController *dataController = [myDataController sharedDataController]; dataController.proteinIsIntendedFor = @"Bakery"; dataController.proteinNotOriginate = @"China"; dataController.proteinHowImportantIsPrice = @"Extremely Important"; dataController.proteinHowImportantIsTaste = @"Somewhat Important"; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; } -(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { if ([[segue identifier] isEqualToString:@"segPopProteinIntendedFor"]) { _pvcSegueProteinIntendedFor = (UIStoryboardPopoverSegue *)segue; _pvcProteinIntendedFor = [segue destinationViewController]; [_pvcProteinIntendedFor setDelegate:self]; } else if ([[segue identifier] isEqualToString:@"segPopProteinNotOriginateFrom"]) { _pvcSegueProteinNotOriginateFrom = (UIStoryboardPopoverSegue *)segue; _pvcProteinNotOriginateFrom = [segue destinationViewController]; [_pvcProteinNotOriginateFrom setDelegate:self]; } else if ([[segue identifier] isEqualToString:@"segPopProteinTaste"]) { _pvcSegueProteinTaste = (UIStoryboardPopoverSegue *)segue; _pvcProteinTaste = [segue destinationViewController]; [_pvcProteinTaste setDelegate:self]; } else if ([[segue identifier] isEqualToString:@"segPopProteinPrice"]) { _pvcSegueProteinPrice = (UIStoryboardPopoverSegue *)segue; _pvcProteinPrice = [segue destinationViewController]; [_pvcProteinPrice setDelegate:self]; } } - (void)dismissPopViewController:(NSString *)value{ [self.btnProteinIntendedFor setTitle:value forState:UIControlStateNormal]; [[_pvcSegueProteinIntendedFor popoverController] dismissPopoverAnimated: YES]; myDataController *dataController = [myDataController sharedDataController]; dataController.proteinIsIntendedFor= value; //[self checkFields]; } - (void)dismissPopProteinIntendedFor:(NSString *)value{ [self.btnProteinIntendedFor setTitle:value forState:UIControlStateNormal]; [[_pvcSegueProteinIntendedFor popoverController] dismissPopoverAnimated: YES]; myDataController *dataController = [myDataController sharedDataController]; dataController.proteinIsIntendedFor= value; //[self checkFields]; } - (void)dismissPopProteinNotOriginateFrom:(NSString *)value { [_btnProteinNotOriginateFrom setTitle:value forState:UIControlStateNormal]; [[_pvcSegueProteinNotOriginateFrom popoverController] dismissPopoverAnimated: YES]; // dismiss the popover myDataController *dataController = [myDataController sharedDataController]; dataController.proteinNotOriginate = value; //[self checkFields]; } - (void)dismissPopProteinTaste:(NSString *)value { [_btnProteinTaste setTitle:value forState:UIControlStateNormal]; [[_pvcSegueProteinTaste popoverController] dismissPopoverAnimated: YES]; // dismiss the popover myDataController *dataController = [myDataController sharedDataController]; dataController.proteinHowImportantIsTaste = value; //[self checkFields]; } - (void)dismissPopProteinPrice:(NSString *)value { [_btnProteinPrice setTitle:value forState:UIControlStateNormal]; [[_pvcSegueProteinPrice popoverController] dismissPopoverAnimated: YES]; // dismiss the popover myDataController *dataController = [myDataController sharedDataController]; dataController.proteinHowImportantIsPrice = value; //[self checkFields]; } -(IBAction)doSomething:(id)sender { self.parentNextButton.enabled = YES; } @end </code></pre> <p>View Controller:</p> <pre><code>#import &lt;UIKit/UIKit.h&gt; #import "resultViewController.h" #import "userInputs.h" #import "embeddedTableViewController.h" @interface rootViewController : UIViewController @property IBOutlet UISwitch *yesNoSwitch; @property (strong, nonatomic) IBOutlet UIButton *btnNext; @property (strong, nonatomic) UIStoryboardPopoverSegue *rcvSegueResults; @property (strong, nonatomic) resultViewController *rvcResults; @property (strong, nonatomic) userInputs *userInputs; - (IBAction)unwindResults:(UIStoryboardSegue *)unwindSegue; - (IBAction)editingChanged:(id)sender; - (IBAction)switchChanged: sender; @end </code></pre> <p>Implementation</p> <pre><code>#import "rootViewController.h" #import "myDataController.h" #import "embeddedTableViewController.h" @interface rootViewController () @end @implementation rootViewController -(void)viewWillAppear:(BOOL)animated { //self.eTableViewController.parentNexButton = self.btnNext; //[self.eTableViewController parentNextButton] = self.btnNext; } -(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { //self.eTableViewController = segue.destinationViewController; } - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; if (self) { } return self; } - (void)viewDidLoad { [super viewDidLoad]; self.title = @"Pick a Protein Choices"; } - (void)viewDidAppear:(BOOL)animated { } - (void)viewDidUnload { [super viewDidUnload]; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; } - (BOOL)prefersStatusBarHidden { return YES; } -(IBAction)switchChanged:(UISwitch *) sender { BOOL setting = sender.isOn; [self.yesNoSwitch setOn:setting animated:YES]; myDataController *dataController = [myDataController sharedDataController]; if (self.yesNoSwitch.isOn) { dataController.proteinMustBeOrganic = YES; } else { dataController.proteinMustBeOrganic = NO; } } //Unwind from Results to Inputs - (IBAction)unwindResults:(UIStoryboardSegue *)unwindSegue { } //Fire this whenever come back from editing; check to see if we should undim button - (IBAction)editingChanged:(id)sender { //*btnNext; } @end </code></pre> <p>OK I still am having an issue. I apologize I am sure it is something stupid.</p> <p>rootViewController.h</p> <pre><code>#import &lt;UIKit/UIKit.h&gt; #import "resultViewController.h" #import "userInputs.h" #import "embeddedTableViewController.h" @interface rootViewController : UIViewController @property IBOutlet UISwitch *yesNoSwitch; @property (strong, nonatomic) IBOutlet UIButton *btnNext; @property (strong, nonatomic) UIStoryboardPopoverSegue *rcvSegueResults; @property (strong, nonatomic) resultViewController *rvcResults; @property (strong, nonatomic) userInputs *userInputs; - (IBAction)unwindResults:(UIStoryboardSegue *)unwindSegue; - (IBAction)editingChanged:(id)sender; - (IBAction)switchChanged: sender; @end </code></pre> <p>rootViewController.m [just top part]</p> <pre><code>#import "rootViewController.h" #import "myDataController.h" #import "embeddedTableViewController.h" @interface rootViewController () @property(strong, nonatomic) UITableViewController *eTableViewController; @end @implementation rootViewController -(void)viewWillAppear:(BOOL)animated { //self.eTableViewController.parentNexButton = self.btnNext; } -(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { self.eTableViewController = segue.destinationViewController; } </code></pre> <p>embeddedTableViewController.h [Top]</p> <pre><code>#import &lt;UIKit/UIKit.h&gt; #import "pvcProteinIntendedFor.h" #import "pvcProteinNotOriginateFrom.h" #import "pvcProteinTaste.h" #import "pvcProteinPrice.h" #import "userInputs.h" @interface embeddedTableViewController : UITableViewController &lt;UITableViewDataSource,UITableViewDelegate,pvcProteinIntendedForDelegate,pvcProteinTasteDelegate,pvcProteinPriceDelegate,pvcProteinNotOriginateFromDelegate&gt; @property(nonatomic, strong) UIButton *parentNextButton; //Buttons for pop @property (weak, nonatomic) IBOutlet UIButton *btnProteinIntendedFor; @property (weak, nonatomic) IBOutlet UIButton *btnProteinNotOriginateFrom; @property (weak, nonatomic) IBOutlet UIButton *btnProteinTaste; @property (weak, nonatomic) IBOutlet UIButton *btnProteinPrice; </code></pre> <p>embeddedTableViewController.m </p> <pre><code>#import "embeddedTableViewController.h" #import "pvcProteinIntendedFor.h" #import "pvcProteinNotOriginateFrom.h" #import "pvcProteinTaste.h" #import "pvcProteinPrice.h" #import "userInputs.h" #import "myDataController.h" @interface embeddedTableViewController () @end @implementation embeddedTableViewController -(IBAction)doSomething:(id)sender { self.parentNextButton.enabled = YES; } </code></pre> <p>The error I get is on this line of code:</p> <pre><code>//self.eTableViewController.parentNexButton = self.btnNext; </code></pre> <p>and the error is</p> <p>Property 'parentNextButton' not found on object of type 'UITableViewController *'</p> <p>I think this is telling me that the eTableViewController is not "seeing" the file and thus can't get at that property.</p>
 

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