1

I am facing a weird problem in ios 7. I designed a controller view using storyboard. I gave each and every constraint proportionally. By each and every I really mean width & height as well as leading, trailing, top and bottom constraints. It's working like a charm in ios 8. My whole view size is getting reduced and increased in proportion to the screen size BUT in ios 7 the view readjusts after appearing and the values are a little deviated from the desired values. Deviation values are not fixed and the constraints which are deviated also vary, each time my controller is pushed or presented.

I think it is because of giving everything proportionally. Some view lifecycle difference in ios 7 and ios 8.

Has anyone ever faced similar problem with ios 7?

(I am using XCode 6.1)

PS: I really have searched and banged my head a lot over past 3-4 days. So please avoid saying "search the net". And I request you to post the link if you know one, which you think can help.

GKK
  • 232
  • 1
  • 3
  • 15

2 Answers2

2

I solved this issue ultimately. (Late in answering but better late than never)

Wherever I was giving a height or width proportional to the controller's view there I gave a fixed constraint in the storyboard and then modified the constant of that constraint's outlet in viewDidLayoutSubviews i.e. I gave the ratio in that method. This problem occurs in iOS7 only and not in iOS8 onwards. In iOS7 the constraints given proportional to the controller's view give a problem. Giving the proportional values programmatically, in viewDidLayoutSubviews (i.e. after the views and subviews have been laid out), the UI behaves correctly.

GKK
  • 232
  • 1
  • 3
  • 15
1

You can follow following one of two options to save yourself unexpected behaviour of the application

  1. You have to use autolayout without size classes implementation for all ios versions. Because size classes are available in ios 8 not in older versions.
  2. If you are developeing application for ios 8 and ios 7 the you have to consider size classes choice as discussed in the answer of the following question. Size Classes implementation to support iOS7, or see this post Size Classes Backward Compatibility
Community
  • 1
  • 1
abrar ul haq
  • 404
  • 3
  • 14
  • Thanks for your reply @abrar. Yes, I am using size classes. I am designing in Any Any. I solved this issue yesterday though. Wherever I was giving a height or width proportional to the controller's view there I gave a fixed constraint in the storyboard and then modified the constant of that constraint's outlet in viewDidLayoutSubviews i.e. I gave the ratio in that method. – GKK Aug 07 '15 at 11:54