我有两个相似的视图,每个人都有一个底部工具栏,里面有一个botton和一个textfield。 (在工具栏自动调整,autolayout& co。不起作用......)在每个控制器中都有方法:
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
if (toInterfaceOrientation == UIDeviceOrientationPortrait || toInterfaceOrientation == UIDeviceOrientationPortraitUpsideDown) {
CGRect frameRect = _totaleTF.frame;
frameRect.size.width = 230;
_totaleTF.frame = frameRect;
CGRect roundRect = _calcolaButton.frame;
roundRect.size.width = 86;
_calcolaButton.frame = roundRect;
} else {
CGRect screenBounds = [[UIScreen mainScreen] bounds];
if (screenBounds.size.height == 568)
{
CGRect frameRect = _totaleTF.frame;
frameRect.size.width = 561;
_totaleTF.frame = frameRect;
CGRect roundRect = _calcolaButton.frame;
roundRect.size.width = 168;
_calcolaButton.frame = roundRect;
} else if(screenBounds.size.height==480) {
CGRect frameRect = _totaleTF.frame;
frameRect.size.width = 442;
_totaleTF.frame = frameRect;
CGRect roundRect = _calcolaButton.frame;
roundRect.size.width = 141;
_calcolaButton.frame = roundRect;
}
}
}
根据屏幕方向调整按钮和文本字段的大小,它们可以正常工作! (哇!!!!)但方法仅适用于他的观点;所以,如果我在view1中旋转屏幕,view2的工具栏将保留以前的大小;我怎么解决呢?非常感谢你!