无法在 Xcode (iPad) 中更改模态视图的呈现和过渡样式
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7740831/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Can't change the presentation and transition styles of modal views in Xcode (iPad)
提问by Dan Cearnau
I'm currently having some trouble with modal views and popovers. It might be the same problem, but I'm not sure.
我目前在模态视图和弹出窗口方面遇到了一些问题。这可能是同样的问题,但我不确定。
The problem I'm having with modal views is that I can't change the animation or transition style. For instance, I write
我在模态视图中遇到的问题是我无法更改动画或过渡样式。例如,我写
self.modalPresentationStyle = UIModalPresentationPageSheet;
self.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentModalViewController:IpModal animated:YES];
but the modal view still appears full screen with its original transition style.
但模态视图仍然以其原始过渡样式全屏显示。
Also, the problem I'm having with popovers is pretty similar. Even though I call the dismissPopover:animated: method with "NO" as the parameter, the transition is still animated.
另外,我遇到的popovers的问题非常相似。即使我使用“NO”作为参数调用了dismissPopover:animated: 方法,过渡仍然是动画的。
Thanks in advance.
提前致谢。
回答by jrturton
modalPresentationStyle
and modalTransitionStyle
apply to the view controller that is to be presented modally, not the controller doing the presenting.
modalPresentationStyle
并modalTransitionStyle
应用于以模态呈现的视图控制器,而不是进行呈现的控制器。
Your code should be
你的代码应该是
IpModal.modalPresentationStyle = UIModalPresentationPageSheet;
IpModal.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentModalViewController:IpModal animated:YES];
回答by Drew
I did this in custom segue.
我在自定义转场中做到了这一点。
UIViewController* src = self.sourceViewController;
UIViewController* dst = self.destinationViewController;
src.modalPresentationStyle = UIModalTransitionStyleFlipHorizontal;
dst.modalPresentationStyle = UIModalTransitionStyleFlipHorizontal;
[src presentModalViewController:dst animated:YES];
回答by madLokesh
#import yourViewController.m //already present
#import destinationVieController.m //to be added by programmer
//custom function to call destination controller
-(void)callDestinationViewController{
destinationViewController *dest = [[destinationViewController alloc] initWithNibName:@"destinationViewController" bundle:nil];
dest.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentModalViewController:dest animated:YES];
}
//custom function can be called on event fire or action call
Hope This Helps !
希望这可以帮助 !
回答by Mundi
Perhaps you could try using one of these two methods to present the popover controller, depending on where you want it to appear, rather than presentModalViewController:animated:
.
也许您可以尝试使用这两种方法之一来呈现弹出控制器,具体取决于您希望它出现的位置,而不是presentModalViewController:animated:
.
– presentPopoverFromRect:inView:permittedArrowDirections:animated:
– presentPopoverFromBarButtonItem:permittedArrowDirections:animated: