简体   繁体   English

从下到上而不是从右到左关闭 UIViewController

[英]Dismiss a UIViewController from bottom to top instead of right to left

I am trying to dismiss a view controller from bottom to top instead of the standard right to left transition.我试图从下到上关闭视图 controller 而不是标准的从右到左过渡。 Is this at all possible?这是可能吗? Here is the code I have so far:这是我到目前为止的代码:

CGRect screenRect = [[UIScreen mainScreen] applicationFrame];

CGRect endFrame = self.view.frame;
endFrame.origin.y = screenRect.origin.y - screenRect.size.height;

UIView *aView = [[self.view retain] autorelease];
[self.view.window addSubview:aView];
aView.frame = CGRectMake(0, 0, 320, 460);
[UIView animateWithDuration:0.5
                 animations:^{
                     [UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
                     aView.frame = endFrame;
                 }
                 completion:^(BOOL finished) {
                     [self dismissModalViewControllerAnimated:NO];
                     [aView removeFromSuperview];
                 }
 ];

This does result in a transition;这确实会导致过渡; but the previous view controller does not appear until after the animation since I can't dismiss until after it completes... any ideas?但是之前的视图 controller 直到 animation 之后才会出现,因为我不能在它完成之前关闭......有什么想法吗?

Aah, when you presentModalViewController, it automatically hides the view behind.啊,当你呈现ModalViewController 时,它会自动将视图隐藏在后面。 What you need to do is not present and remove, but add the view controllers view as a subview of the main view.您需要做的不是存在和删除,而是添加视图控制器视图作为主视图的子视图。 Then you just animate the view offscreen, and removeFromSuperview in the competition handler.然后,您只需为屏幕外的视图设置动画,并在比赛处理程序中 removeFromSuperview 。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 UISplitViewController从上到下而不是从右到左过渡 - UISplitViewController transition from top to bottom instead of right to left 你如何从屏幕顶部而不是底部呈现UIViewController? - How do you present a UIViewController from the top of the screen instead of the bottom? UIViewController从右到左过渡 - UIViewController Transition from right to left 向左/右滑动UIViewcontroller - Sliding UIViewcontroller to left/right 关闭UIViewController而不关闭顶部的警报 - Dismiss a UIViewController without dismissing an alert on top of it Objective-C UITableViewCell左/右/上/下空间 - Objective-C UITableViewCell left/right/top/bottom space 如何通过从UIViewController向右或向左滑动来更改UIImageView中的图像 - How to change image from UIImageView by sliding right or left from UIViewController 如何为 UIView 的左下角、右下角和左上角设置 cornerRadius? - how to set cornerRadius for only bottom-left,bottom-right and top-left corner of a UIView? UISplitViewController从右边而不是左边显示弹出框 - UISplitViewController display the popover from right instead of left 如何在MapKit中获取地图的左上角和右下角经度 - How to get left-top and right-bottom latitude and longitude of map in MapKit
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM