Search code examples
iphoneobjective-ciosipadmbprogresshud

MBProgresshud set it in landscape


i am implementing MBProgresshud in my app in AppDelegate file

-(void)showProgressHUD:(NSString*)msg{
if(mbProcess!=nil && [mbProcess retainCount]>0){ 
    [mbProcess removeFromSuperview];
    [mbProcess release];
    mbProcess=nil;
}
mbProcess=[[MBProgressHUD alloc] initWithWindow:self.window];
mbProcess.labelText=@"";
mbProcess.detailsLabelText = msg;
[self.window addSubview:mbProcess];
[mbProcess setDelegate:(AppDelegate*)[[UIApplication sharedApplication]delegate]];
[mbProcess show:YES];
}

i called in DidFinish launching

like [self showProgressHUD:@"Loading..."];

My app is in default Landscape method.

Now the issue is when the app start the progress hud first set into portrait and then in a second, it rotate in landscape.

I need this hud all time in landscape

thank you


Solution

  • Since MBProgressHud is a subclass of UIView, you can try to rotate manually your progressHud before show it ?

    mbProcess.transform = CGAffineTransformMakeRotation(angle);
    [self.window addSubview:mbProcess];
    [mbProcess show:YES];
    

    Careful angle should be in radian (so for a 90° rotation you should use something like M_PI/2 or (-M_PI/2))