SNR
SNR

Reputation: 1249

Change the orientation of view in iPhone


I want to change a view's orientation as and when it is displayed.
For Example:
Whenever the user clicks a button a new view is displayed to the user. Whatever may be the orientation,I want to display this view in Landscape mode.
Any Ideas.....

Upvotes: 0

Views: 478

Answers (3)

itZme
itZme

Reputation: 1439

Use this function in your class.

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations

   return (interfaceOrientation == UIInterfaceOrientationLandscapeRight ||                        
   interfaceOrientation == UIInterfaceOrientationLandscapeLeft);

}

Upvotes: 2

visakh7
visakh7

Reputation: 26390

Add this to your view controller

- (BOOL)shouldAutorotateToInterfaceOrientationUIIn terfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight );
    } 

Upvotes: 0

PgmFreek
PgmFreek

Reputation: 6402

Add this function the in the new view to change the Orientation to landscape mode.

- (BOOL)shouldAutorotateToInterfaceOrientationUIIn terfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight );
    } 

Upvotes: 2

Related Questions