ios跳转到指定controller非常简单,需要使用navigationController对象,首先我们需要目标controller的storyboard ID,如下图。

然后使用以下方式进行controller跳转。
GroupViewController *goupVC = [[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"GroupList"]; [self.navigationController pushViewController:goupVC animated:YES];
如果要携带参数到目标controller,需要先在目标controller的.h文件内设置属性,如我要传递groupId和groupName,就在GroupViewController.h页面添加如下属性。
@interface GroupViewController : UIViewController @property (nonatomic, strong) NSString *groupId; @property (nonatomic, strong) NSString *groupName; @end
实现prepareForSegue方法将以上两个参数携带到GroupViewController中,代码如下。
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
//向下一个控制器传值
id destVC = segue.destinationViewController;
//判断是否是GroupViewController
if ([destVC isKindOfClass:[GroupViewControllerclass]]) {
[destVC setGroupId:@"123456"];
[destVC setGroupName:@"创业群"];
}
}