- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我想通过 segue 将我的 View Controller “滑出”到 destinationViewController
上方。这是我的代码:
override func perform()
{
let src = self.sourceViewController
let dst = self.destinationViewController
dst.view.superview?.insertSubview(src.view, aboveSubview: dst.view)
src.view.transform = CGAffineTransformMakeTranslation(0, 0)
UIView.animateWithDuration(0.25,
delay: 0.0,
options: UIViewAnimationOptions.CurveEaseInOut,
animations: {
src.view.transform = CGAffineTransformMakeTranslation(src.view.frame.size.width * -1, 0)
},
completion: { finished in
src.presentViewController(dst, animated: false, completion: nil)
}
)
}
幻灯片看起来不错,但是在动画期间 destinationViewController 是全黑的,当动画完成时 destinationViewController 正确显示。
如何让它在 segue 动画期间显示?
编辑:
解决了:
override func perform()
{
let src = self.sourceViewController
let dst = self.destinationViewController
src.view.superview?.insertSubview(dst.view, belowSubview: src.view)
dst.view.transform = CGAffineTransformMakeTranslation(0, 0)
UIView.animateWithDuration(0.25,
delay: 0.0,
options: UIViewAnimationOptions.CurveEaseInOut,
animations: {
src.view.transform = CGAffineTransformMakeTranslation(src.view.frame.size.width * -1, 0)
},
completion: { finished in
src.presentViewController(dst, animated: false, completion: nil)
}
)
}
最佳答案
试试这个:
class FirstCustomSegue: UIStoryboardSegue {
override func perform() {
// Assign the source and destination views to local variables.
var firstVCView = self.sourceViewController.view as UIView!
var secondVCView = self.destinationViewController.view as UIView!
// Get the screen width and height.
let screenWidth = UIScreen.mainScreen().bounds.size.width
let screenHeight = UIScreen.mainScreen().bounds.size.height
// Specify the initial position of the destination view.
secondVCView.frame = CGRectMake(screenWidth, 0.0, screenWidth, screenHeight)
// Access the app's key window and insert the destination view above the current (source) one.
let window = UIApplication.sharedApplication().keyWindow
window?.insertSubview(secondVCView, aboveSubview: firstVCView)
// Animate the transition.
UIView.animateWithDuration(0.4, animations: { () -> Void in
firstVCView.frame = CGRectOffset(firstVCView.frame, -screenWidth, -0.0)
secondVCView.frame = CGRectOffset(secondVCView.frame, -screenWidth, -0.0)
}) { (Finished) -> Void in
self.sourceViewController.presentViewController(self.destinationViewController as! UIViewController,
animated: false,
completion: nil)
}
}
}
关于ios - UIStoryboardSegue sourceViewController 在 destinationViewController 之上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32693611/
我看过几个示例如何使用自定义动画呈现自定义 UIStoryboardSegue。基本上,您将 UIStoryBoardSegue 子类化并覆盖“perform”方法,即像这样: - (void)per
我有一个 UIStoryboardSegue 子类,用于将当前 View Controller 替换为下一个 View Controller 。 因为我们在界面编辑器中有一个 Animates 属性,
这个问题已经有答案了: Sharing an Image between two viewControllers during a transition animation (2 个回答) 已关闭 5
我目前正在构建一个目录结构,这应该能让我在我的 iOS 项目中更清楚地使用 MVC 模型。因此,我为我的 Models、Views、Controllers 和集成的 API 创建了一个文件夹,但不知道
我有一个带有一个 ViewController 和四个 UIStoryboardSegue 的 Storyboard。导航工作完美,但如果我想在 UIStoryboardSegue 中包含一个 web
有人可以解释使用 UIStoryboardSegue modal 与以编程方式使用 presentViewController 之间的区别吗? 使用UIStoryboardSegue只是为了方便?或者
所以我有一个 UITableView,并且单元格连接到 UIStoryboardSegue 以便打开一个新的 UIViewController。单击单元格后 prepareForSegue get 被
我以编程方式将 UIButton 附加到 navigationBar: catButton.addTarget(self, action: "oc:", forControlEvents: .Touc
自定义过渡对我来说相当陌生。我不得不将它们合并到我工作的最后一个项目中,并最终使用 UIViewControllerAnimatedTransitioning 协议(protocol)和自定义 seg
这就是我现在做的: func presentOverlayController(controller: UIViewController) { controller.modalPresenta
当我的自定义 segue 动画正在执行时,目标 View 显示为黑色。动画结束后出现 View ,看起来不错。 截图如下: 动画场景: 转场/动画完成后的 View : 这是自定义转场类: class
我正在编写一个应用程序,我需要在其中使用相当“复杂”的 UIStoryboardSegue。设计师给了我以下内容: 现在 segue 背后的基本思想很简单,向上滑动 source.view,然后再向上
我有以下 swift 代码,我想要实现的是从顶部滑出的 segue。我希望第二个 VCView 位于第一个 VCView 下方,并且让第一个 VCView 滑出显示第二个 VCView。 目前没有动画
我正在使用 Xcode 6.1 尝试创建从左到右的自定义转场。我正在学习本教程 click here .将类 NSObject 更改为 UIStoryboardSegue 时卡住了,如下所示: #im
我正在尝试将 Objective-C 方法转换为 Swift。 Objective-C 方法如下: - (void)prepareForSegue:(UIStoryboardSegue *)segue
有谁知道如何有条件地“停止”segue 转换: 我的表格 View 单元格代表可以在向下钻取的“详细信息” View 中查看的产品……或者不能! (这取决于几件事) 现在我的应用认为所有产品都已“解锁
我在创建自定义转场时遇到问题:我正在重写“perform()”方法,如下所示 override func perform() { if !isBack { self.desti
我有一个小型应用程序,它包含一个带有 UIImageView 的 View Controller 。当用户点击屏幕时,会显示一个带有自定义转换的 tableview Controller (模型)。过
我编写了一个自定义的 UIStoryboardSegue。 我的 CustomSegue.m 文件中的唯一代码是: -(void) perform { UIViewController* so
我编写了一个自定义的 UIStoryboardSegue,我用它在各种 UIViewControllers 之间进行转换。动画按预期工作,大部分时间 UIStoryboardSegue 在模拟器和设备
我是一名优秀的程序员,十分优秀!