开发者

Xcode Orientation UIView

I would like to use a different UIV开发者_运维百科iew for Landscape than for Portrait mode, is that possible and if so how do I do this?


Take a global variable say "currentOrientationView" in .h file. When ever your device is going to rotate from any interface orientation it will call "WillRotateToInterfaceOrientation:",this method has a parameter that tells the interface orientation to which the device is going to rotate so put your condition in this method and set the value of "currentOrientationView" with corresponding view as:

-(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration{
if (UIInterfaceOrientationIsPortrait(toInterfaceOrientation)) {
    currentOrientationView=potraitView;
}else {
    currentOrientationView=landscapeView;;
}}


you must use the method shouldAutorotatetointerface orientation, and inside this method you have to put code like

[self.addSubview:newView];


Use willRotateToInterfaceOrientation to exchange views. shouldAutorotateToInterfaceOrientation should return YES for all orientations you'd like to support.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜