I use transitionFromView
switch two UIView ,But there is somethine wrong with it , When I transition the view to second UIView ,it work ok, then I transition the view back The error is happen(the location of first UIView is wrong)
What happen?
self.primaryView.hidden = !self.primaryView.hidden self.secondaryView.hidden = !self.secondaryView.hidden println("\(self.primaryView)") UIView.transitionFromView(displayingPrimary ? self.primaryView : self.secondaryView, toView: displayingPrimary ? self.secondaryView : self.primaryView, duration: 1.0, options: nil ) { (finish) -> Void in if finish { println("after:\(self.primaryView)") self.displayingPrimary = !self.displayingPrimary; } }
this is print info in console
<UIView: 0x79fe3c80; frame = (0 0; 399 349); hidden = YES; autoresize = RM+BM; layer = <CALayer: 0x79fe3d10>>
after:<UIView: 0x79fe3c80; frame = (0 0; 399 349); hidden = YES; autoresize = RM+BM; layer = <CALayer: 0x79fe3d10>>
<UIView: 0x79fe3c80; frame = (0 0; 399 349); autoresize = RM+BM; layer = <CALayer: 0x79fe3d10>>
after:<UIView: 0x79fe3c80; frame = (-436 -328; 399 349); autoresize = RM+BM; layer = <CALayer: 0x79fe3d10>>