Reputation: 375
I have a tabbed Iphone project in which I am attempting to present one modal segue but from multiple different view controllers.
Essentially I want it to function the same way the stock music app works in IOS 9 for iphone. You can be in any one different tab and still be able to view the account page.
First problem/question. How to mimic this behavior without making a ton of segues. Currently I have 3 separate views that I want to call a modal segue from but how can I achieve this without making duplicate segues
Second problem/question. How to dismiss the modal view without it becoming a deprecated segue. I have found tuts on how to do this but they require another segue back to the "sender" view controller.
If only apple could provide some decent sample code to aid my efforts in my attempt to do this...
Upvotes: 0
Views: 148
Reputation: 27428
you can present and dissmiss any view controller object without segue like below,
UIViewController *vc = [[UIViewController alloc]init]; // your view controller here
// You can present VC like
[self presentViewController:vc animated:YES completion:^{
// do your task on completion
}];
// In your Presented VC you can dissmiss it like
[self dismissViewControllerAnimated:YES completion:^{
//do your task on completion
}];
Update as per comment :
You can instantiate story board like,
SideMenuViewController *vc = [self.storyboard instantiateViewControllerWithIdentifier:@"sideMenu"];
Here SideMenuViewController
is custom viewController class set to viewcontroller from storyboard.
And make sure you have set storyboard Id
under identity from identity inspector
. Here my sideMenu
is storyboard Identity!
So you can instantiate your storyboard viewcontroller like this and then present it as mentioned before
Hope this will help :)
Upvotes: 1