iOS 7是否在UINavigationController内显示模式视图?

iOS 7是否在UINavigationController内显示模式视图?,ios,iphone,objective-c,uinavigationcontroller,Ios,Iphone,Objective C,Uinavigationcontroller,我的应用程序是使用UINavigationController为所有导航设置的。我想使用一个模式转换来呈现应用程序中的特定视图控制器。问题是,我想将新的VC嵌入导航控制器中,但一个视图需要使用模态动画,而不是推送 如何在UINavigationController中的单个视图控制器上实现此模式动画/转换 请记住,在此模式动画发生后,该页面上的按钮将按照标准的UINavigationController按钮动画继续工作 模式视图默认为全屏。您需要更改演示文稿样式以显示导航栏 编辑:这只适用于iPa

我的应用程序是使用UINavigationController为所有导航设置的。我想使用一个模式转换来呈现应用程序中的特定视图控制器。问题是,我想将新的VC嵌入导航控制器中,但一个视图需要使用模态动画,而不是推送

如何在UINavigationController中的单个视图控制器上实现此模式动画/转换


请记住,在此模式动画发生后,该页面上的按钮将按照标准的UINavigationController按钮动画继续工作

模式视图默认为全屏。您需要更改演示文稿样式以显示导航栏

编辑:这只适用于iPad。对于iPhone,您可以使用或获得半模态行为

MyModalViewController *targetController = [[[MyModalViewController alloc] init] autorelease]; targetController.modalPresentationStyle = UIModalPresentationFormSheet; targetController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal; //transition shouldn't matter [self presentModalViewController:targetController animated:YES]; targetController.view.superview.frame = CGRectMake(0,44/*navigation bar's height*/,height, width);//it's important to do this after // use full screen height and width here targetController.view.superview.center = self.view.center; MyModalViewController*targetController=[[MyModalViewController alloc]init]autorelease]; targetController.modalPresentationStyle=UIModalPresentationFormSheet; targetController.ModAltTransitionStyle=UIModAltTransitionStyleFlipHorizontal//过渡不重要 [自我呈现ModalViewController:targetController动画:是]; targetController.view.superview.frame=CGRectMake(0,44/*导航栏的高度*/,高度,宽度)//之后再做这件事很重要 //此处使用全屏高度和宽度 targetController.view.superview.center=self.view.center;
默认情况下,模式视图为全屏。您需要更改演示文稿样式以显示导航栏

编辑:这只适用于iPad。对于iPhone,您可以使用或获得半模态行为

MyModalViewController *targetController = [[[MyModalViewController alloc] init] autorelease]; targetController.modalPresentationStyle = UIModalPresentationFormSheet; targetController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal; //transition shouldn't matter [self presentModalViewController:targetController animated:YES]; targetController.view.superview.frame = CGRectMake(0,44/*navigation bar's height*/,height, width);//it's important to do this after // use full screen height and width here targetController.view.superview.center = self.view.center; MyModalViewController*targetController=[[MyModalViewController alloc]init]autorelease]; targetController.modalPresentationStyle=UIModalPresentationFormSheet; targetController.ModAltTransitionStyle=UIModAltTransitionStyleFlipHorizontal//过渡不重要 [自我呈现ModalViewController:targetController动画:是]; targetController.view.superview.frame=CGRectMake(0,44/*导航栏的高度*/,高度,宽度)//之后再做这件事很重要 //此处使用全屏高度和宽度 targetController.view.superview.center=self.view.center; 用视图控制器名称替换伪代码


用视图控制器名称替换伪代码。

对于iOS7,可以使用新的自定义转换API。您可以在此处找到更多信息:


创建动画控制器(交互式或其他),并将其传递到导航栏代理的相应方法中。在动画控制器中,使用
UIView
animation API执行自定义动画。在您的情况下,对于正向动画,动画应该执行从下到下的滑动,对于反向动画,应该执行从下到下的滑动。如果您支持交互式动画,您甚至可以控制动画相对于手指滑动的曲线。

对于iOS7,这可以使用新的自定义转换API实现。您可以在此处找到更多信息:


创建动画控制器(交互式或其他),并将其传递到导航栏代理的相应方法中。在动画控制器中,使用
UIView
animation API执行自定义动画。在您的情况下,对于正向动画,动画应该执行从下到下的滑动,对于反向动画,应该执行从下到下的滑动。如果您支持交互式动画,您甚至可以控制动画相对于手指滑动的曲线。

使用此行非presentModelViewController

[self presentViewController:vc animated:YES completion:Nil];  

使用此行不显示ModelViewController

[self presentViewController:vc animated:YES completion:Nil];  
最简单的方法

呈现

LaunchImageViewController *launchView = [self.storyboard instantiateViewControllerWithIdentifier:@"launchImage"];
[[UIApplication sharedApplication].keyWindow addSubview:launchView.view];
结束。我将其称为内部呈现(LaunchImageViewController)

最简单的方法

呈现

LaunchImageViewController *launchView = [self.storyboard instantiateViewControllerWithIdentifier:@"launchImage"];
[[UIApplication sharedApplication].keyWindow addSubview:launchView.view];
结束。我将其称为内部呈现(LaunchImageViewController)


也许这样的东西对你有用(self是UINavigationController):


也许这样的东西对你有用(self是UINavigationController):


忘记有类似模态的东西,做一个presentModalView。这应该行得通。在iOS 7中,presentModalViewController不受欢迎,当我执行该方法时,它会将该视图从UINavigationController中删除。我的意思是[self.navigationController presentViewController:yourViewController…]模式视图始终是全屏的,但是,您可以更改presentationstyle。忘记有类似modal的内容,然后执行presentModalView。这应该行得通。在iOS 7中,presentModalViewController不受欢迎,当我执行该方法时,它会将该视图从UINavigationController中删除。我的意思是[self.navigationController presentViewController:yourViewController…]模式视图始终是全屏的,但是,您可以更改presentationstyle。正如在原始问题的评论中提到的,
presentModalViewController
已被弃用。@PeterFoti他可以使用替代API,但逻辑是相同的。他正在为iPhone开发,这些是iPad API
modalPresentationStyle
仅在iPad上以模式显示视图控制器时(正式)才被考虑。正如在原始问题的评论中提到的,
presentModalViewController
不受欢迎。@Peter他可以使用替代API,但逻辑是相同的。他正在为iPhone开发,这些是ipadapi
modalPresentationStyle
仅在iPad上以模式显示视图控制器时(正式)才被考虑。这确实有效,但它将新显示的VC从UINavigationController中移除。我想我真正想问的是,如何用一个从屏幕底部向顶部滑动的动画来呈现导航控制器的一部分视图,类似于标准的模式转换。我需要UINavigationBar在这个动画之后保持,这样我就可以继续推新的