gpt4 book ai didi

iphone - MBProgressHud 不随设备方向改变。?

转载 作者:行者123 更新时间:2023-11-28 18:41:12 24 4
gpt4 key购买 nike

我正在使用 MBProgressHud 在启动 View 上显示加载指示器,但这不会随着设备方向的改变而改变。我的代码是:

splashView = [[UIImageView alloc] initWithFrame:self.window.frame];

if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{
splashView.image = [UIImage imageNamed:@"DefaultPad.png"];
}
else
{
splashView.image = [UIImage imageNamed:@"Default.png"];
}

hud = [[MBProgressHUD alloc]initWithView:splashView];
[splashView addSubview:hud];

hud.userInteractionEnabled=NO;
hud.labelText = @"Loading...";

[hud show:YES];

[self.window addSubview:splashView];
[self performSelector:@selector(Load_FirstView) withObject:nil afterDelay:3];
[self.window makeKeyAndVisible];

并且我更改了 MBProgressHud.m 文件中的行

- (void)deviceOrientationDidChange:(NSNotification *)notification { 

NSLog(@"in device orientation ");
UIView *superview = self.superview;
if (!superview) {
return;
} else if ([superview isKindOfClass:[UIWindow class]]) { // here changes have done
[self setTransformForCurrentOrientation:YES];
} else {
self.bounds = self.superview.bounds;
[self setNeedsDisplay];
}
}

到:

- (void)deviceOrientationDidChange:(NSNotification *)notification { 

NSLog(@"in device orientation ");
UIView *superview = self.superview;
if (!superview) {
return;
} else if ([superview isKindOfClass:[UIImageView class]]) {
[self setTransformForCurrentOrientation:YES];
} else {
self.bounds = self.superview.bounds;
[self setNeedsDisplay];
}
}

如何让加载指示器随设备方向旋转?

最佳答案

在 MBProgressHUD.m 我改变了

UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation;

UIInterfaceOrientation orientation = [[UIDevice currentDevice] orientation];

已经收到方向通知,但是statusBar还没有旋转。

关于iphone - MBProgressHud 不随设备方向改变。?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10613609/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com