Log in or register to post comments

Auto rotation on iphone

October 12, 2011 - 12:58am #1

Hi,

I m newbie to iOS and QualComm so please bare with me. I m developing an app in which when any Frame Marker gets detected, i will show an image to the user. I used overlaid image for the same and it is working fine but when i change from Landscape mode to Portrait, the overlaid image does not rotate. Can someone please show me that what i m doing wrong?????

Also, when i try to use "shouldAutorotateToInterfaceOrientation" method in ARViewController file, it rotate image but camera in Portrait mode is not showing properly. The camera show only landscap view and also the half screen of iphone is blank in Portrait mode. So I don't know what to do in this situation. Please help me.

I used below code for overlaid image:

FrameMarkersAppDelegate:

UIView* parentV = [[UIView alloc] initWithFrame:screenBounds];

screenBounds = CGRectMake(0, 0, parentV.frame.size.height, parentV.frame.size.width);
view = [[EAGLView alloc] initWithFrame: screenBounds];
[parentV addSubview:view];

UIImage *rightImage = [UIImage imageNamed:@"right.png"];
UIImageView *rightImageView = [[UIImageView alloc] initWithImage:rightImage];

rightImageView.center = parentV.center;

view.rightImageView = rightImageView;
view.rightImageView.hidden = YES;
rightImageView.hidden = YES;

[rightImage release];
[parentV addSubview:rightImageView];

[viewController setView:parentV];

[window addSubview: viewController.view];
[window makeKeyAndVisible];

To show the image in EAGLView.mm file, i changed below code:

switch (marker->getMarkerId()) {
case 0:
[self performSelectorOnMainThread:@selector(showRightImageView) withObject:nil waitUntilDone:NO];
break;

- (void) showRightImageView
{
rightImageView.hidden = NO;
}

Thanks,
Hardik

Re: Auto rotation on iphone

October 17, 2011 - 4:45am #8
hardik_vh wrote:

It worked now, sorry for posting again and again. I changed x and y coordinate to show it properly on landscape mode.

:-) Well done for working it out!

Re: Auto rotation on iphone

October 17, 2011 - 4:39am #7

It worked now, sorry for posting again and again. I changed x and y coordinate to show it properly on landscape mode.

Thanks
Hardik

Re: Auto rotation on iphone

October 17, 2011 - 12:26am #6

Hi MoSR,

I tried that OverlayView solution for rotation issue but it is not working in my case. I implemented "shouldAutorotate..." method in my controller for image rotation and for camera rotation in eagl view but the image rotate perfectly but the camera shows only landscape view and the half screen of iphone is blank in Portrait mode. So I don't know what to do in this situation. Why Camera is not rotating properly? is SDK has control over the camera rotation?

Please help me soon

Thanks,
Hardik

Re: Auto rotation on iphone

October 14, 2011 - 6:39am #5

I got it worked. Actually, I m newbie to iOS so i don't know how to handle multiple views but at the end I understood the problem now it solved :).

What I did is that I created root controller and added eagl view controller and overlyview controller to it and then show the view accordingly.

Thanks for all the help.

-Hardik

Re: Auto rotation on iphone

October 14, 2011 - 4:43am #4

Hi Hardik, can you confirm that you solution is based on this specific post:
http://ar.qualcomm.at/node/2000724

The most common reasons for not seeing the camera view are:

A) QCAR can't find your EAGLView in the window hierarchy, or it's renderFrameQCAR, (the log will advise of this issue)

or

B) the onResume() isn't being called after onCreate().

Re: Auto rotation on iphone

October 13, 2011 - 11:27pm #3

Hi MoSR,

Let me first tell you what i am planning to do using FrameMarker QCAR. I want to start QCAR based on let say some button press and also want to stop QCAR. What I did that based on other forum thread http://ar.qualcomm.at/node/2000724

for Reinitialising QCAR, I crated separate methods to start and stop QCAR. I called these methods on button click event. I have also used OverlayView that you suggested earlier. Now what happens is that it shows me initial screen with buttons and when I press button to start QCAR. it initialized everything but screen shows me white background and not starting Camera. I checked that it execute startCamera method but it does not show it on screen. Even when I tap on screen, it shows me alert box with all four Camera options that defines in Overlay view.

So can you please help me to identify the problem? I hope I have made my self clear.

Thanks,
Hardik

Re: Auto rotation on iphone

October 12, 2011 - 12:21pm #2

Hi Hardik

I think you just need to add a View Controller to the view you want to autorotate, that needs to implement shouldAutoRotate... See the 'overlayViewController.m' in the ImageTargets example - it does exactly that. As long as you have no other view controllers elsewhere that should be okay - you may find you need to add the subviews to your UIWindow rather than a parent view for that to work - iOS is a bit sensitive about these things.

Log in or register to post comments