Reputation: 8327
I've reviewed all the other similar problems and can't find solution.
My iPad storyboard has a Tab Bar Controller as the "initial View Controller", which links through a "Relationship Seque view controllers" to a Navigation Controller, which links through a "root view" link, to View Controller A, which has a UIButton, which links through a 'Manual Seque push' to View Controller B.
Tab Bar Cntrl => Navigation Cntrlr ==(root view)==> View Cntrl A, UIButton ==(push)==> View Cntrl B
So, when running, with View Controller A shown, pressing its UIButton needs to change to View Controller B. But nothing happens................
THE DELEGATE THAT RESPONDS TO UIBUTTON (PRESS-AND-HOLD gesture)............
- (void)schedule_long_press_delegate:(UILongPressGestureRecognizer *)recognizer { if (recognizer.state == UIGestureRecognizerStateEnded) { printf("Long press Ended ................. \n");
// Get storyboard:
UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPad"
bundle: nil];
printf("mainStoryboard = %x \n", (int)mainStoryboard ); // !!! ax
// Get nav controller for MANAGE view:
UINavigationController *MANAGE_UINavigationController = (UINavigationController*)[mainStoryboard
instantiateViewControllerWithIdentifier: @"MANAGE_Storyboard_ID"];
printf("MANAGE_UINavigationController = %x \n", (int)MANAGE_UINavigationController ); // !!! ax
// Get MANAGE view's view controller:
SCHEDULE_UIViewController *schedule_UIViewController = [self.storyboard instantiateViewControllerWithIdentifier:
NSStringFromClass([SCHEDULE_UIViewController class])];
printf("schedule_UIViewController = %x \n", (int)schedule_UIViewController ); // !!! ax
// Change screen to MANAGE view:
[MANAGE_UINavigationController pushViewController: schedule_UIViewController animated:YES];
}
else {
printf("Long press detected ..................... \n");
}
}
STORYBOARD SETTINGS:
UITabBarController ... Storyboard ID is blank. ..links to: UINavigationController ... Class=UINavigationController StoryboardID = "MANAGE_Storyboard_ID" ..links to: UIViewController ... Class=acc StoryboardID is blank (INITIAL VIEW) ..links to: UIViewController ... Class & StoryboardID = "SCHEDULE_UIViewController" (TARGET VIEW)
OUTPUT:..........
When the delegate fires, it displays the pointers, which are all set:
mainStoryboard = 1f8b4900
MANAGE_UINavigationController = 1e5d45f0
schedule_UIViewController 2 = 1e5d4b20
Is there some initialization that I'm missing?
Upvotes: 0
Views: 822
Reputation: 31026
The word "instantiate" tells you that you are creating a new instance. Therefore, when you call:
UINavigationController *MANAGE_UINavigationController = (UINavigationController*)[mainStoryboard instantiateViewControllerWithIdentifier: @"MANAGE_Storyboard_ID"];
You are creating a new navigation controller which is not the one that's currently part of the visible hierarchy.
Although your objects and calls may be fine, you're not interacting with the controllers that are managing the screen.
(Note: If you used code style that matched Apple standards, if would be a lot easier for other people to analyze what you've written.)
Upvotes: 1