开发者

How to set the view in a landscape mode in iPad?

开发者 https://www.devze.com 2023-02-12 05:16 出处:网络
I\'m working with iPad. I want my app to fix at lanscape mode only. My app contains a split view controller and above split view controller I placed login screen.

I'm working with iPad. I want my app to fix at lanscape mode only. My app contains a split view controller and above split view controller I placed login screen.

After user provides the necessary username and password, the login view should be removed so that split view controller gets o开发者_Go百科pened. It works good. But i want login screen to be set at landscape mode. I tried in so many ways but my problem is still not solved. I placed a UIOrientaion key with value lanscape in a plist. But no use.

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {

    //UIInterfaceOrientationLandscapeLeft;
    // Overriden to allow any orientation.
 //  return UIInterfaceOrientationIsLandscape(interfaceOrientation);
    return YES;
    //return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft);
}

I tried in this way also but no result.

[[UIDevice currentDevice] setOrientation:UIInterfaceOrientationLandscapeLeft];

Also in this way in viewdidload,

By using this way im able to set the app in landscape mode but the view is not rotated to landscape.The login view is fixed at potrait mode.

In nib file,if i fix the view in lanscape,the split view's,rootviewcontroller appears on on e side and in the detailviewcontroller of splitviewcontroller,this login screen is opened that too in potrait mode.....

Any help will be appreciated Thanks in advance


i found solution to my problem.Here is the coding:

[ViewController *newDetailViewController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil];
[window addSubview:newDetailViewController.view];    
[window addSubview:anotherViewController.view];
[window bringSubviewToFront:newDetailViewController.view];

In this way we should add subviews to delegate.After that fix the view in landscape by auto rotation method in view controllers..thats it

0

精彩评论

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

关注公众号