Question

i will like to know how to set the ar view into landscape mode.

NSLog(@"bound %@",NSStringFromCGRect([self.view bounds]));
    NSLog(@"bound %@",NSStringFromCGRect([[UIScreen mainScreen] bounds]));

    glView = [[ARView alloc] initWithFrame:[[self view] bounds] pixelFormat:kEAGLColorFormatRGBA8 depthFormat:GL_DEPTH_COMPONENT16_OES stencilFormat:0 preserveBackbuffer:NO];
    glView.arViewController = self;

    self.view = glView;

    UIToolbar *toolbar = [[UIToolbar alloc] init];
    toolbar.frame = CGRectMake(0, 255, 480, 44);
    toolbar.barStyle = UIBarStyleBlack;

    NSMutableArray *items = [[NSMutableArray alloc] init];
    [items addObject:[[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(stopAR:)] autorelease]];
    [toolbar setItems:items animated:NO];
    [items release];    
    [self.view addSubview:toolbar];
    [toolbar release];

tried to set this but no effect

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    [super shouldAutorotateToInterfaceOrientation:interfaceOrientation];
    return UIInterfaceOrientationIsLandscape(interfaceOrientation);   
}
Was it helpful?

Solution

I wonder why you want to do this. The ARView just shows the video from the camera. The model will be displayed with respect to the marker-orientation. Hence it's not necessary to handle landscape or portrait modus. If you have an overlay view than you should handle orientation change there.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top