Reputation: 105
SO I would like to know if there is a possibility to make a call from a view in the code to go to another view, not using segue.
Thanks for the help.
Upvotes: 5
Views: 7556
Reputation: 17732
Yes, if you are using a navigation controller, you simply need to push onto the navigation controller:
[self.navigationController pushViewController:otherViewCon animated:YES];
Or, if you want a modal transition:
[self presentModalViewController:otherViewCon animated:YES];
This is all assuming self
is a UIViewController.
To get otherViewCon
from a storyboard designed view controller:
otherViewCon = [self.storyboard instantiateViewControllerWithIdentifier:@"Other View"];
Upvotes: 7
Reputation: 6803
Example of presenting a popover:
//Declare popover controller
UIPopoverController *paparazzi;
//Just some Interface Builder action (could be triggered by a button)
- (IBAction)sigFocus:(id)sender
{
//A view controller being made from a xib file
SigPopView *temp = [[SigPopView alloc] initWithNibName:@"SigPopView" bundle:nil];
//Sets the view controller to be displayed
paparazzi = [[UIPopoverController alloc] initWithContentViewController:temp];
//Set size
[paparazzi setPopoverContentSize:CGSizeMake(480,179)];
//Show controller
[paparazzi presentPopoverFromRect:theSignature.frame inView:(UIView *)self.delegate permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
}
Upvotes: 0