开发者

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 vi开发者_开发百科ew is displayed to the user. Whatever may be the orientation,I want to display this view in Landscape mode.

Any Ideas.....


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 );
    } 


Use this function in your class.

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

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

}


Add this to your view controller

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜