我的要求是在人像模式這是我的第一個視圖 - 控制開only.and當用戶進入第二視圖 - 控制我想在風景模式控制器如何可以我這樣做1日的ViewController在縱向和SecondViewController在橫向模式
我試着這個代碼
1 ViewController.m
- (BOOL)shouldAutorotate
{
returnc YES;
}
-(NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
return UIInterfaceOrientationMaskPortrait;
}
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interface
{
return (interface==UIInterfaceOrientationMaskPortrait);
}
守則第2 ViewController.m
- (BOOL)shouldAutorotate
{
return YES;
}
-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskLandscapeRight | UIInterfaceOrientationMaskLandscapeLeft;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return UIInterfaceOrientationLandscapeRight;
//return UIInterfaceOrientationMaskLandscape;
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationLandscapeRight || interfaceOrientation == UIInterfaceOrientationLandscapeLeft);
}
這對我來說工作不正常。
有什麼不合適呢?描述你遇到的問題。 –
當用戶去第二個控制器顯示protrait模式我希望它在橫向模式 – Jitendra
我回答了類似的問題,它可以幫助。 http://stackoverflow.com/questions/18185260/view-controllers-in-view-controller-and-orientation-ios/18185775#18185775 – BoranA