在Objective C中导航到下一页

时间:2017-10-05 05:34:55

标签: ios objective-c iphone

点击按钮,我想导航到下一页。我的故事板id = first AND class = ViewController我想在其故事板中导航id = next和class = second。如何导航到它。如何在目标c ??

中做到这一点

1 个答案:

答案 0 :(得分:2)

在Obj-C

//Write here your's storyboard name
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"myNewStoryboard" bundle:nil];
//Now write your next view controller and write your storyboard id.
MyNewViewController *myNewVC = (MyNewViewController *)[storyboard instantiateViewControllerWithIdentifier:@"MyNewViewController"];
[self.navigationController pushViewController:myNewVC animated:YES];

在Swift中

//Write here your's storyboard name
let storyboard: UIStoryboard = UIStoryboard.init(name: "myNewStoryboard", bundle: nil)
 //Now write your next view controller and write your storyboard id.
let myNewVC = storyboard.instantiateViewController(withIdentifier: "MyNewViewController") as? MyNewViewController
self.navigationController?.pushViewController(myNewVC!, animated: true)