1

我是IOS平台的新手,在研究了它的工作原理后,我对如何调用新的类/视图并在按下按钮时覆盖当前视图有疑问。在android中我这样做:

Intent intent = new Intent(a.class, b.class);
startActivity(intent);

在互联网上搜索,我注意到我必须使用导航栏才能做到这一点。我用标签栏控制器启动了一个应用程序并放置了一个导航控制器。我使用了下面的代码:

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Storyboard" bundle:nil];
UIViewController *myController = [storyboard instantiateViewControllerWithIdentifier:@"Dicas"];
[self.navigationController pushViewController: myController animated:YES];

并返回: 在此处输入图像描述 有办法覆盖当前视图吗?我总是必须使用导航栏来调用另一个类(使用底部 e 上层控制器会使我的应用程序变得丑陋)?

4

4 回答 4

0

As you said u want to overlay your current view so not sure but You can show your view controller using model view like this

yourViewController *secView = [[YourViewController alloc] initWithNibName:@"YourViewController" bundle:nil];
[secView setModalPresentationStyle:UIModalPresentationPageSheet];//u can use different UIModalPresentationStyle
[secView setModalTransitionStyle:UIModalTransitionStyleCoverVertical];
[self.navigationController presentViewController:secView animated:YES completion:nil];

Above one will show your view controller over existing view controller, once presented you need to make provision to dismiss this modal view.

于 2014-08-01T13:10:12.437 回答
0

要隐藏导航栏:

[[self navigationController] setNavigationBarHidden:YES animated:YES];

隐藏标签栏:

yourViewController.hidesBottomBarWhenPushed = YES;
于 2014-08-01T13:02:45.013 回答
0

您还可以使用 viewController 类的 presentViewController 函数调用另一个 viewController。

[self presentViewController: myController animated:YES completion:nil];
于 2014-08-01T13:05:48.443 回答
0

像这样呈现新类或 ViewController 的简单方法..

  ViewController *view = [self.storyboard instantiateViewControllerWithIdentifier:@"ViewController"];
  [self presentViewController:view animated:YES completion:nil];
于 2014-08-01T13:23:38.760 回答