所以我想知道是否有可能从代码中的一个视图调用以转到另一个视图,而不是使用 segue。
谢谢您的帮助。
是的,如果您使用的是导航控制器,您只需要推送到导航控制器:
[self.navigationController pushViewController:otherViewCon animated:YES];
或者,如果你想要一个模态转换:
[self presentModalViewController:otherViewCon animated:YES];
这一切都假设self
是一个 UIViewController。
从otherViewCon
故事板设计的视图控制器中获取:
otherViewCon = [self.storyboard instantiateViewControllerWithIdentifier:@"Other View"];
呈现弹出框的示例:
//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];
}