从 presentModalViewController 推送 uiviewcontroller
Posted
技术标签:
【中文标题】从 presentModalViewController 推送 uiviewcontroller【英文标题】:push uiviewcontroller from presentModalViewController 【发布时间】:2011-07-21 08:13:00 【问题描述】:我使用presentModalViewController
显示视图。从这个UIView
我想使用UINavigationController
推送UIView
。
我为此尝试了以下代码
[self.parentViewController.navigationController
pushViewController:objViewFullScreen
animated:YES];
但这对我不起作用。所以请任何人建议我如何从ModelViewController
推送视图。
谢谢
【问题讨论】:
【参考方案1】:首先,您必须在导航控制器中展示您的模态视图控制器:
MyViewController *vc = [[MyViewController alloc] initWithNibName:@"MyNib" bundle:nil];
UINavigationController *nc = [[UINavigationController alloc] initWithRootViewController:vc];
[self presentModalViewController:nc animated:YES];
[vc release];
[nc release];
那么在MyViewController
里面你可以这样做:
OtherViewController *vc = [[OtherViewController alloc] initWithNibName:@"MyOtherNib" bundle:nil];
[self.navigationController pushViewController:vc animated:YES];
[vc release];
【讨论】:
感谢您的快速回复。这个对我有用。但vc视图不透明。我还设置了 [uicolor clearcolor],但它不适用于我。所以你能建议我如何让它透明吗?谢谢 ***.com/questions/849458/…【参考方案2】:-(void)pushViewControllerWithCustomAnimation:(UIViewController *)newViewController
newViewController.view.alpha = 0.0f;
[self.view addSubview:newViewController.view];
[UIView animateWithDuration:1
animations:^
newViewController.view.alpha = 1;
completion:^(BOOL fin)
if (fin)
// finally display the new viewcontroller for real
[self.navigationController pushViewController:newViewController animated:NO];
];
【讨论】:
以上是关于从 presentModalViewController 推送 uiviewcontroller的主要内容,如果未能解决你的问题,请参考以下文章
为啥 [UIViewController presentModalViewController:animated:] 从左侧过渡模态视图?
嵌套在 UIScrollview 中的 ViewController 中的 presentModalViewController?
presentModalViewController 是 pushviewcontroller 内存消耗
presentViewController pushViewController和presentModalViewController
presentViewController pushViewController和presentModalViewController