0

My app has a button which rotates my view 90 degrees and changes its frame accordingly so it fills the screen in landscape.

The code is as following:

CGAffineTransform transform = CGAffineTransformRotate(self.tabsView.transform, M_PI_2);

self.tabsView.transform = transform;


CGRect newFrame = CGRectMake( self.view.frame.origin.x, self.view.frame.origin.y, self.view.frame.size.width, self.view.frame.size.height);

self.tabsView.frame = newFrame;

It works like a charm on iOS 10 and lower: Lanscape iOS 10

But running it on Xcode 9 beta 6 in the iOS 11 simulator I get this result: Landscape iOS 11

Is this a bug or did anything change in this version I don't know about? I use Auto Layout.

Kian
  • 122
  • 13
  • don't you think after transformation, view's height will become width and Width become height? – Suryakant Sharma Sep 06 '17 at 05:32
  • @Suryakant I thought that too at first but doing that just causes wrong results on iOS 10 and still no affect on iOS 11. The code itself is correct, it just seems like its not being executed on iOS 11 and I don't know why. – Kian Sep 06 '17 at 11:38

1 Answers1

2

I just found the solution. It was necessary to add this line of code:

self.tabsView.translatesAutoresizingMaskIntoConstraints = YES;

It translates the views autoresizing mask into Auto Layout constraints. With that I have the same result on both iOS versions.

Kian
  • 122
  • 13