我正在使用 MBProgressHud 在初始视图上显示加载指示器,但这不会随设备方向而改变。我的代码是:
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];
}
}
如何让加载指示器随设备方向旋转?