閑話不多說(shuō)先上效果圖


這里面用的present?頁(yè)面切換
1.先在AppDelegate中重寫-(UIInterfaceOrientationMask)application:(UIApplication*)application supportedInterfaceOrientationsForWindow:(UIWindow*)window方法,交代進(jìn)入的BaseNavi,以及RootView。代碼如下
- (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions {
// Override point for customization after application launch.
self.window= [[UIWindowalloc]initWithFrame:[[UIScreenmainScreen]bounds]];
[self.windowsetBackgroundColor:[UIColorwhiteColor]];
UIStoryboard*storyBoard = [UIStoryboardstoryboardWithName:@"Main"bundle:[NSBundlemainBundle]];
ViewController*vc = [storyBoardinstantiateViewControllerWithIdentifier:@"ViewController"];
BaseViewController* nav = [[BaseViewControlleralloc]initWithRootViewController:vc];
[self.windowsetRootViewController:nav];
[self.windowmakeKeyAndVisible];
returnYES;
}
-(UIInterfaceOrientationMask)application:(UIApplication*)application supportedInterfaceOrientationsForWindow:(UIWindow*)window{
returnUIInterfaceOrientationMaskAll;
}
2.創(chuàng)建一個(gè)BaseNavi,就是上一步用到的。方法寫上
- (BOOL)shouldAutorotate
{
return[self.topViewControllershouldAutorotate];
}
- (UIInterfaceOrientationMask)supportedInterfaceOrientations
{
return[self.topViewControllersupportedInterfaceOrientations];
}
3.在第一個(gè)頁(yè)面寫上,支持旋轉(zhuǎn) 但是這個(gè)頁(yè)面只支持豎屏,代碼:
//支持旋轉(zhuǎn)
-(BOOL)shouldAutorotate{
returnYES;
}
//支持的方向因?yàn)榻缑鍭我們只需要支持豎屏
- (UIInterfaceOrientationMask)supportedInterfaceOrientations {
returnUIInterfaceOrientationMaskPortrait;
}
4.第二個(gè)頁(yè)面我們寫上,我們所需要的橫屏效果,代碼:
//支持旋轉(zhuǎn)
-(BOOL)shouldAutorotate{
returnYES;
}
//
//支持的方向
- (UIInterfaceOrientationMask)supportedInterfaceOrientations {
returnUIInterfaceOrientationMaskLandscapeLeft;
}
//一開(kāi)始的方向很重要
-(UIInterfaceOrientation)preferredInterfaceOrientationForPresentation{
returnUIInterfaceOrientationLandscapeLeft;
}
以上就是橫屏設(shè)置了,代碼不到位的,請(qǐng)多包涵。