Self.view setFrame does not work with iOS 8 and Nav Controller

Someone noticed that self.view setFrame stops working with Nav Controller in iOS 8. It works fine if there is no nav controller in the view controller, but otherwise it doesn’t. Does anyone know a job? I am currently using

[self.view setFrame:CGRectMake(0,-100,[[UIScreen mainScreen] bounds].size.width,[[UIScreen mainScreen] bounds].size.height)]; 

But that doesn't work anymore

+5
source share
2 answers

Try setting setTranslatesAutoresizingMaskIntoConstraints to YES before setting the frame:

 [self.view setTranslatesAutoresizingMaskIntoConstraints:YES]; 

And then set your frame:

 [self.view setFrame:CGRectMake(0,-100,[[UIScreen mainScreen] bounds].size.width,[[UIScreen mainScreen] bounds].size.height)]; 
+16
source

I don’t know if setFrame has changed, but I can say that the β€œrestrictions” have changed in iOS 8, where the bounds property of the UIScreen class now reflects the orientation of the device, so the width and height will pop up when in the landscape.

iOS 8 offers a new nativeBounds property on UIScreen that does not change with orientation, but note that it is measured in pixels, not points.

0
source

Source: https://habr.com/ru/post/1202846/


All Articles