"We offer new support options and therefor the forums are now in read-only mode! Please check out our Support Center for more information." - Vuforia Engine Team

How to properly deal with rotations?

Hi,

I have some GUI of my own inside CROverlayViewController and one starting screen inside CRParentViewController. What is the proper way, to place GUI elements depending on device rotation? Now I have that starting CloudReco sample using push segue (storyboard in use), whatever is orientation in app menu, CloudReco itself is starting with the same as menu and GUI looks good (corner images are in fact in corners). However GUI looks good before rotation, after it's a mess. If you change from portrait to landscape inside CloudReco part all elements that were below certain height will not be shown after rotation to landscape...

Only rotation code of CRParentViewController is called:

- (BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation{
    //  Since CRParentViewController does not inherit from BaseViewController,
    //  we have to override this behavior
    
    BOOL retVal = [[CRQCARutils getInstance] shouldAutorotateToInterfaceOrientation:toInterfaceOrientation];
    return retVal;
//    return YES;
}

-(void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation{
    NSLog(@"CRPVC: didRotateFromInterfaceOrientation");
    [UIView animateWithDuration:0.5 animations:^{
        [startView setCenter:self.view.center];
    }];
}

but CROverlayViewController not:

- (BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation{
    NSLog(@"CROVC: shouldAutorotate");
    //  Since CRParentViewController does not inherit from BaseViewController,
    //  we have to override this behavior
    BOOL retVal = [[CRQCARutils getInstance] shouldAutorotateToInterfaceOrientation:toInterfaceOrientation];
    return retVal;
//    return YES;
}

What's more, animating startView makes it move from ealier center to the newer one. I wish I could make all elements stay on their place.

 

Here are logs from rotations: (VC stands for ViewController ;) )

2013-04-04 14:49:51.593 CloudReco[1046:707] OVC: handleViewRotation
2013-04-04 14:49:51.595 CloudReco[1046:707] CRVC: handleARViewRotation
2013-04-04 14:49:51.597 CloudReco[1046:707] CRVC: Rotating to Landscape Left
2013-04-04 14:49:51.600 CloudReco[1046:707] EAGLView: layoutSubviews
2013-04-04 14:49:51.604 CloudReco[1046:707] EAGLView: initRendering
2013-04-04 14:49:51.913 CloudReco[1046:707] CRPVC: didRotateFromInterfaceOrientation

 

Btw, the UILabel with pointing device hint I have added to CRParentViewController (because tapped it should start Vuforia) and rest has been added in CROverlayViewController.

Thanks a lot, looks good :) where did you get this storyboard version ? do you have it to check segues and stuff? Maybe my fault is in connections, anyway love to see this "pro storyboard" CloudReco :)

p.s. I'll use next time "attach" ;)