Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You could add a <code>property</code> to your <code>SubNavView</code> class that will hold the tag of the button pressed. Then, when you create an instance of <code>SubNavView</code> set that property before showing it. You will also need to save the selected tag in an ivar of <code>MainNavView</code> so you can set the selected tag in <code>SubNavView</code>.</p> <p>Here is an example:</p> <p><strong>SubNavViewController.h</strong></p> <pre><code>@interface SubNavViewController : UIViewController @property (nonatomic, strong) NSInteger tagSelected; // The rest of your class declaration @end </code></pre> <p><strong>MainNavViewController.m</strong></p> <pre><code>@interface MainNavViewController () // This is the ivar to save the selected tag @property (nonatomic, strong) NSInteger tagSelected; @end @implementation MainNavViewController () // Your class code -(IBAction)pushButton:(id)sender { int theTag = ((UIView *) sender).tag; // save the tag that was selected for later use sefl.tagSelected = theTag; switch (theTag) { // The rest of your switch here... } } - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { // Make sure your segue name in storyboard is the same as this line if ([[segue identifier] isEqualToString:@"segueToSubNav"]) { // Get reference to the destination view controller SubNavViewController *vc = [segue destinationViewController]; // Tell SubNavView which button was pressed... vc.selectedTag = self.selectedTag; // Pass any objects to the view controller here, like... [vc setMyObjectHere:buttons]; } } @end </code></pre> <p>After that, when <code>SubNavView</code>'s <code>viewDidLoad</code> is called you can use an <code>if-else</code> clause to create your buttons:</p> <pre><code>-(void)viewDidLoad { [super viewDidLoad]; if (self.selectedTag == 1) { //Do something... } else if (self.selectedTag == 2) { //Do something else... } // etc... } </code></pre> <p>Hope this helps!</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.
    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