我在iOS6上工作,我的UIToolbar在设备旋转时没有变得更薄,尽管它正在加宽以覆盖增加的长度。这是我的代码:
-(void)loadToolBar:(NSString *)t {
//Creates a toolbar.
[bar removeFromSuperview];
if (UIDeviceOrientationIsLandscape([[UIDevice currentDevice] orientation])) {
bar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, 480, 32)];
}
else bar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, 320, 44)];
bar.autoresizingMask=UIViewAutoresizingFlexibleWidth;
bar.autoresizingMask=UIViewAutoresizingFlexibleHeight;
bar.autoresizingMask=UIViewAutoresizingFlexibleBottomMargin;
}
我还从UIToolbar height on device rotation添加了这个方法,但它似乎没有什么区别:
- (void) layoutForInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Adjust the toolbar height depending on the screen orientation
CGSize toolbarSize = [bar sizeThatFits:self.view.bounds.size];
bar.frame = (CGRect){CGPointMake(0.f, CGRectGetHeight(self.view.bounds) - toolbarSize.height), toolbarSize};
webV.frame = (CGRect){CGPointZero, CGSizeMake(CGRectGetWidth(self.view.bounds), CGRectGetMinY(bar.frame))};
}
关于我做错了什么的想法?