use*_*217 10 navigation uibutton uiviewcontroller ios
我是iOS应用程序开发的新手,请帮助我如何通过按钮点击从一个view controller到另一个view controller?
按照以下步骤,让按钮选择器
[button addTarget:select action:@selector(buttonClick) forControlEvents:UIControlEventTouchUpInside];
并将选择器实现为
-(void)buttonClick{
UIViewController *controler = [[UIViewController alloc] init];
[self.navigationController pushViewController:controler animated:YES];}
Run Code Online (Sandbox Code Playgroud)
并确保viewController中嵌入了NavigationController,并将UIViewController替换为您想要推送的Controller.
小智 7
试试这个:
nextViewController *obj =[[nextViewController alloc]initWithNibName:@"nextViewController" bundle:nil];
[self.navigationController pushViewController:obj animated:YES];
[obj release];
Run Code Online (Sandbox Code Playgroud)
小智 6
在您Objective-C的导航功能中使用此代码-
DashboardViewController *dvc = [self.storyboard instantiateViewControllerWithIdentifier:@"DashboardView"];
[dvc setModalTransitionStyle:UIModalTransitionStyleCoverVertical];
[self presentViewController:dvc animated:YES completion:nil];
Run Code Online (Sandbox Code Playgroud)
您可以使用任何一种方法-
pushViewController:动画:-在导航堆栈上推送视图
presentModalViewController:nc动画:-以模态显示视图。
YourSecondViewcontroller *temp = [[YourSecondViewcontroller alloc]initWithNibName:@"YourSecondViewcontroller" bundle:nil];
[self.navigationController pushViewController:temp animated:YES];
Run Code Online (Sandbox Code Playgroud)
//或者
[self presentModalViewController:temp animated:YES];
Run Code Online (Sandbox Code Playgroud)
Visit this reference for tutorial and working demo code
希望,这会帮助你..享受
| 归档时间: |
|
| 查看次数: |
47136 次 |
| 最近记录: |