Reputation: 4764
I am trying to tag an item in IOS. On the item page, I'd like to have a link to the tag. However, the screen for the tag varies based on the tag.
Example, for an item of clothing, if it is tagged, shirt, I'd like the shirt tag to point to the shirt page, if the tag is jacket, I'd like to point to the jacket tag etc.
For this reason, I cannot hardwire a segue in Storyboard to a given view controller. Can anyone suggest a way to point to different view controllers based on the tag.
Thanks in advance for any suggestions.
Upvotes: 0
Views: 35
Reputation: 38162
Assuming, in your storyboard, you have view controller pages defined for all your tags,
performSegueWithIdentifier:sender:
like this->
-(IBAction)linkButtonPressed:(id)sender {
if (shirtPageCondition == YES) {
[self performSegueWithIdentifier:@"shirtPage" sender:nil];
} else if (jacketPageCondition == YES) {
[self performSegueWithIdentifier:@"jacketPage" sender:nil];
}
}
Upvotes: 1
Reputation: 2011
There are various methods and properties of UIViewController you can chose
Presenting View Controllers
modalPresentationStyle [Property]
modalTransitionStyle [Property]
modalInPopover [Property]
- showViewController:sender:
- showDetailViewController:sender:
- presentViewController:animated:completion:
- dismissViewControllerAnimated:completion:
definesPresentationContext [Property]
providesPresentationContextTransitionStyle [Property]
- disablesAutomaticKeyboardDismissal
Also you can instantiate view controllers with Storyboard or just UIViewController classes yourself in the code.
For example
let shirtViewController: ShirtViewController = UIStoryboard(name: "Shirt", bundle: NSBundle.mainBundle()).instantiateInitialViewController() as! ShirtViewController
presentViewController(shirtViewController, animated: true, completion: nil)
Upvotes: 0