且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在单击按钮时从一个视图控制器导航到另一个视图控制器?

更新时间:2023-01-04 21:22:29

按照下面的步骤,让按钮选择器是

Follow the below step,let the button selector is

[button addTarget:select action:@selector(buttonClick) forControlEvents:UIControlEventTouchUpInside];并将选择器实现为

-(void)buttonClick{
UIViewController *controler = [[UIViewController alloc] init];
[self.navigationController pushViewController:controler animated:YES];}

并确保 viewController 中嵌入了 NavigationController,并将 UIViewController 替换为您希望推送的控制器.

and also make sure viewController has NavigationController embedded within it and replace UIViewController with the Controller you wish to push.