方法一:
需要有Navigation Controller,单ViewController时,选择后可以通过菜单上的Editor》Embed In》Navigation Controller添加,子ViewController不需要连线,直接用下面方法跳转就行。
UIStoryboard *story = [UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]]; UIViewController *myView = [story instantiateViewControllerWithIdentifier:@"AViewController"]; [self.navigationController pushViewController:myView animated:YES];
返回可以用[self.navigationController popViewControllerAnimated:YES];或前面的方法跳转
方法二:
还有一种情况是没有Navigation Controller时,则采用以下方法跳转
UIStoryboard *story = [UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]]; UIViewController *myView = [story instantiateViewControllerWithIdentifier:@"AViewController"]; [self presentViewController:myView animated:YES completion:nil];
返回可以用[self dismissModalViewControllerAnimated:YES];或前面的方法跳转