Когда выполняется моя анимация пользовательского segue, вид назначения отображается черным. После окончания анимации открывается и выглядит хорошо.UIStoryboardSegue: вид не отображается во время анимации
Вот скриншоты:
Анимация сцены:
Просмотреть после SEGUE/анимация закончена:
Вот класс пользовательских Segue:
class SegueToPreview: 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(0.0, screenHeight, 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.2, 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)
}
}
Пока нет ind segue работает отлично, показывая оба представления.
Я полагаю, что представление не загружается во время анимации, но понятия не имеет, как это исправить.
Возможно, вы неуместны коды пользовательского интерфейса в viewDidAppear вместо этого? технически он загружен уже потому, что вы вызвали self.destinationViewController.view – JayVDiyk
Кроме того, я думаю, вы должны инициализировать кадр кадра второгоViewController в viewDidLoad. – JayVDiyk