为什么我的UIToolbar在旋转时改变宽度但不改变高度?

时间:2013-01-25 23:07:24

标签: ios objective-c rotation

我在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))};
}

关于我做错了什么的想法?

0 个答案:

没有答案