Has anyone noticed that self.view setFrame has stopped working with Nav Controller in iOS 8. It works just fine if the view controller does not have a nav controller, but otherwise, it doesnt. Does anyone know a work around? Currently I am using
有没有人注意到这个自我。在ios8中,view setFrame已经停止使用Nav控制器。如果视图控制器没有nav控制器,它就可以正常工作,但如果没有,它就不会。有人知道附近有什么工作吗?目前我用
[self.view setFrame:CGRectMake(0,-100,[[UIScreen mainScreen] bounds].size.width,[[UIScreen mainScreen] bounds].size.height)];
But this doesnt work anymore
但这已经行不通了
2 个解决方案
#1
16
Try to set "setTranslatesAutoresizingMaskIntoConstraints" to YES before setting the frame:
在设置框架之前,尝试将“settranslatesautoresizingmaskintoconstraint”设置为“是”:
[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)];
#2
0
I don't know if setFrame has changed, but I can say that 'bounds' has changed in iOS 8 where the bounds property of the UIScreen class now reflects the device orientation, so the width and height will swop when in landscape.
我不知道setFrame是否发生了变化,但是我可以说,在iOS 8中,“界限”发生了变化,UIScreen类的边界属性现在反映了设备的方向,因此在横向时,宽度和高度会发生变化。
iOS 8 offers a new nativeBounds property on UIScreen that doesn't change with orientation, but note that it is measured in pixels, not points.
iOS 8在UIScreen上提供了一个新的nativeBounds属性,它不会随方向变化,但请注意,它是用像素来度量的,而不是点。
#1
16
Try to set "setTranslatesAutoresizingMaskIntoConstraints" to YES before setting the frame:
在设置框架之前,尝试将“settranslatesautoresizingmaskintoconstraint”设置为“是”:
[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)];
#2
0
I don't know if setFrame has changed, but I can say that 'bounds' has changed in iOS 8 where the bounds property of the UIScreen class now reflects the device orientation, so the width and height will swop when in landscape.
我不知道setFrame是否发生了变化,但是我可以说,在iOS 8中,“界限”发生了变化,UIScreen类的边界属性现在反映了设备的方向,因此在横向时,宽度和高度会发生变化。
iOS 8 offers a new nativeBounds property on UIScreen that doesn't change with orientation, but note that it is measured in pixels, not points.
iOS 8在UIScreen上提供了一个新的nativeBounds属性,它不会随方向变化,但请注意,它是用像素来度量的,而不是点。