我有两个相似的视图,每个人都有一个底部工具栏,里面有一个按钮和一个文本字段。(在工具栏中自动调整大小、自动布局和 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 的工具栏将保持以前的大小;我该如何解决?非常感谢!