0

I wrote this class to create a dynamically sized (Kinda like a SVG but in Swift) logo (As a UIView subclass). It works perfectly if i add it to my View Controller's view's subviews in View Did Appear... but it will not work if I add it in View did load. Its a really strange problem that I cannot figure out.

EDIT: The problem only occurs when I do the transformation, if i dont do the transformation, The 4 subviews show up fine, but when i try to rotate them they vanish all together when implemented in View Did Load. And the transformation works in view did appear.

Here is the pastebin for the class I wrote.

MingMan
  • 911
  • 1
  • 10
  • 31

1 Answers1

0

I assume that the problem is that in the viewDidLoad method, the view is not visible, and that time it is pointless (forbidden?) to animate anything. But when the viewDidAppear called, the views are visible and from that you can animate things.

Dániel Nagy
  • 11,815
  • 9
  • 50
  • 58
  • Thanks for the reply - So that would seem like a strange behavior to me if you try to transform to early that it would vanish completely, but i guess ill try to research more. The issue is I dont want to init and add this view on view did appear because thats inefficient - It would happen more frequently than neccessary. If there was a method such as parentviewcontroller did appear i guess i could put the transformation there – MingMan Jan 16 '15 at 16:32
  • check this answer: http://stackoverflow.com/questions/19033942/how-can-i-do-uiview-animatewithduration-in-viewdidload-ios7 I understand your problem, you can add your view in viewDidLoad but with a delay, or in viewDidAppear but with a flag, showing that whether it is added already or not. But there are a lot more ways. – Dániel Nagy Jan 16 '15 at 16:36