12

I have these ViewControllers added in storyboard:

enter image description here

None is connected with a custom class, everything is from pure storyboard.

Video on iPhone simulator on iOS7

This only happens when using AutoLayout on iOS7.

Anyone else seen this?

Download sample project of problem

Arbitur
  • 38,684
  • 22
  • 91
  • 128
  • Are you referring to the way in which the title comes from the middle of the viewController? – Woodstock May 28 '15 at 15:00
  • Mostly the label with text "WTF?" That looks weird – Arbitur May 28 '15 at 15:15
  • If you look at my image you can see that I did add the label using storyboard and it is using autolayout. And in the video you can see the weird transition animation which I did not add, its just a simple Show action. – Arbitur May 28 '15 at 15:18
  • My guess is that autolayout is being caught in the animation block for the viewController presentation. – Woodstock May 28 '15 at 15:32
  • Yes it seems to be what is happening but why and how to fix or is this just a weird bug? Using xcode 6.3.2. – Arbitur Jun 01 '15 at 09:51
  • I found that when the prompt changes from vc to another vc then it animates that change and inside that animation the whole view gets trapped and animates everything when autolayout is applied. – Arbitur Jun 01 '15 at 11:16
  • What storyboard segue are you using? – Horatio Jun 02 '15 at 23:17
  • @Arbitur When i try and use your example program, everything works perfectly on iOS7.1 and iOS8 building with xcode 6.3.2. Any chance it could be an anomaly with your environment or am I running it wrong? Might be worth deleting your app from your simulator and building clean? – Rory McKinnel Jun 05 '15 at 11:29
  • This is still easily reproducable with storyboards and code in Xcode 7.0.1 and it drives me nuts. Anyone got a workaround for this? – JonEasy Oct 21 '15 at 07:17
  • 1
    This still occurs in Xcode 8. Has anyone found a solution? – Nick Kohrn Sep 08 '16 at 14:04
  • I see the same thing in Xcode 8.1. – Craig Otis Nov 09 '16 at 18:55

3 Answers3

4

I think this problem occurs when view is getting autolayout and setting it size to main screen size. In iOS 7 navigation push animation come before view size is set so we can see that animating. Don't worry it works well in iOS 8.0 and later. For iOS 7.0 you can give size of view in viewDidLoad so it can adjust size before it appears.

pkamb
  • 33,281
  • 23
  • 160
  • 191
sschunara
  • 2,285
  • 22
  • 31
3

Edit 2:

As someone mentionned in the comments, I am unable to reproduce the problem with your sample project. One thing I noticed though, is that your project is configured with a deployment target that is iOS 8.3. Here are the steps to fix that :

Step 1: Select your project in Xcode's Project Navigator. Step 2: Make sure you select your project in the left column of the project editor and not the target Step 3: Select the Build Settings tab Step 4: Modify the iOS Deployment Target to iOS 7.1 or iOS 7.0 depending on which OS you are testing with. Step 5: Build and run.

Hopefully this will help you out.

Edit:

Step1. Select your UIViewController with the label 14 and in the third tab of the right pane of Xcode, enter a Storyboard ID such as vc14.

Step2. Select your UIViewController with the label 12 and in the same tab, enter a custom class such as ViewController.

Step3. Remove the trigger segue action from your Button and replace it by a @IBAction in ViewController

Step4. Add this code to your @IBAction in ViewController :

@IBAction func push(sender: AnyObject) {
    var vc14 = self.storyboard?.instantiateViewControllerWithIdentifier("vc14") as! UIViewController
    vc14.view.layoutIfNeeded()
    self.navigationController?.pushViewController(vc14, animated: true)
}

Explanation:

The weird animation is occurring because layout has never occurred before the segue pushes the UIViewController in the UINavigationController. iOS 7 didn't protect appropriately against such a scenario by manually calling layoutIfNeeded before entering an animation block and when the layout finally occurs, it triggers implicit animations. In the code sample I have given you, I manually trigger layout before pushing the ViewController on the stack in order to avoid this issue.

Dalzhim
  • 1,970
  • 1
  • 17
  • 34
  • First, try changing the prompt within the block the same way you used to. – Dalzhim Jun 03 '15 at 13:51
  • I really have no idea how the F apple coded this but it feels very badly written... – Arbitur Jun 04 '15 at 11:24
  • The wrong deplayment target was just a miss from me because I created that project just to give you guys the problem but I forgot to set the target to ios 7............ Anyways its on ios7 i had problems so just change the target. – Arbitur Jun 06 '15 at 08:58
  • Alright, well there must be other differences between your real project and the one that has the problem because I can't seem to reproduce it. Can you confirm which version of Xcode you are using and which minor version of iOS 7. – Dalzhim Jun 06 '15 at 10:36
0

i think you Press ⌘T. so the Slow animation is start. Check the all Simulator you Use.

Debug->Slow Animation

I attach Image check it. See Image