Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/102.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 为什么我的UIToolbar在旋转时改变宽度而不是高度?_Ios_Objective C_Rotation - Fatal编程技术网

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

Ios 为什么我的UIToolbar在旋转时改变宽度而不是高度?,ios,objective-c,rotation,Ios,Objective C,Rotation,我在iOS6中工作,当设备旋转时,我的UIToolbar的高度没有变薄,尽管它正在变宽以覆盖增加的长度。这是我的密码: -(void)loadToolBar:(NSString *)t { //Creates a toolbar. [bar removeFromSuperview]; if (UIDeviceOrientationIsLandscape([[UIDevice currentDevice] orientation])) { bar = [[UIT

我在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;
}
我还从中添加了此方法,但似乎没有什么不同:

- (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))};
}

有没有想到我做错了什么?

你有没有在
中调用
布局进行界面定位:
将动画定位到界面定位:持续时间
视图将出现
?就是这样!非常感谢。这与您的问题无关,但可能会让您省去一些心痛:您正在使用UIDevice的
方向
属性,这可能会产生一些奇怪的结果,除了您预期的4个方向之外,还有
UIDeviceOrientationFaceUp
UIDeviceOrientationFaceDown
我会在您所在的UIViewController子类上使用属性
interfaceOrientation
,因为这是一种
ui接口定向
类型,它只有你关心的4个方向。谢谢你的提醒。我试试看。