问题描述
我是iOS应用程序开发的新手,请帮助我如何从一个视图控制器
转到另一个视图控制器
点击按钮?
I am new to iOS Application development, please help me how can I go from one view controller
to another view controller
on button click?
推荐答案
按照以下步骤,让按钮选择器
Follow the below step,let the button selector is
[button addTarget:select action:@selector(buttonClick)forControlEvents:UIControlEventTouchUpInside];
并将选择器实现为
[button addTarget:select action:@selector(buttonClick) forControlEvents:UIControlEventTouchUpInside];
and implement the selector as
-(void)buttonClick{
UIViewController *controler = [[UIViewController alloc] init];
[self.navigationController pushViewController:controler animated:YES];}
并确保viewController中嵌入了NavigationController,并将UIViewController替换为您想要推送的Controller。
and also make sure viewController has NavigationController embedded within it and replace UIViewController with the Controller you wish to push.
这篇关于如何在按钮单击时从一个视图控制器导航到另一个视图控制器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!