a级 久久,99里面有精品,亚洲av一级免费在线观看,成人免费中文字幕

iOS強制橫向或強制縱向

強制橫屏:強制豎屏:因為在大部分的場景中,只有個別頁面有橫屏的情況,所以基本上都是豎屏,所以我在處理這兩種情況的時候,優(yōu)先選擇使用系統(tǒng)提供的方法:然后在你想橫屏的控制器加上這段代碼,基本上橫屏問題就可以搞定了,前提是你的這個控制器是moda出來的,如果是push的話就要使用上文提到的強制橫豎屏的方法,下面這段代碼是不起作用的在需要設置橫屏的控制器的中添加下面代碼:...

第一種方案(不推薦,直接跳過看第二種方案):

-,需要:

強制橫豎屏,在某些情況下很重要,我在網(wǎng)上找了很多解決方法,但都沒有找到解決方法,請原諒我有點笨,但糾結了一段時間,終于解決了這個問題,會出現(xiàn)不能轉屏?。?!

//強制轉屏
- (void)interfaceOrientation:(UIInterfaceOrientation)orientation
{
    if ([[UIDevice currentDevice] respondsToSelector:@selector(setOrientation:)]) {
        SEL selector  = NSSelectorFromString(@"setOrientation:");
        NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[UIDevice instanceMethodSignatureForSelector:selector]];
        [invocation setSelector:selector];
        [invocation setTarget:[UIDevice currentDevice]];
        int val = orientation;
        // 從2開始是因為0 1 兩個參數(shù)已經(jīng)被selector和target占用
        [invocation setArgument:&val atIndex:2];
        [invocation invoke];
    }
}

勢力景觀:

[self interfaceOrientation:UIInterfaceOrientationLandscapeRight];

強制豎屏:

安卓強制橫屏軟件下載_安卓強制橫屏軟件下載_強制橫屏軟件漢化版

[self interfaceOrientation:UIInterfaceOrientationPortrait];

終于解決了這個頭疼的問題,哈哈哈---啊---duang

在某個界面只提供屏幕旋轉的解決方案如下。

-(UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {
    
    NSLog(@"0000000---------%@",NSStringFromClass([[self topViewController] class]));
    if ([NSStringFromClass([[self topViewController] class]) isEqualToString:@"想要提供轉屏的控制器的名字"]) {
      //橫屏
        return UIInterfaceOrientationMaskLandscapeRight;
    }
      //豎屏
    return UIInterfaceOrientationMaskPortrait;
}
//獲取界面最上層的控制器
- (UIViewController*)topViewController {
    return [self topViewControllerWithRootViewController:[UIApplication sharedApplication].keyWindow.rootViewController];
}
//一層一層的進行查找判斷
- (UIViewController*)topViewControllerWithRootViewController:(UIViewController*)rootViewController {
    if ([rootViewController isKindOfClass:[UITabBarController class]]) {
        UITabBarController* tabBarController = (UITabBarController*)rootViewController;
        return [self topViewControllerWithRootViewController:tabBarController.selectedViewController];
    } else if ([rootViewController isKindOfClass:[UINavigationController class]]) {
        UINavigationController* nav = (UINavigationController*)rootViewController;
        return [self topViewControllerWithRootViewController:nav.visibleViewController];
    } else if (rootViewController.presentedViewController) {
        UIViewController* presentedViewController = rootViewController.presentedViewController;
        return [self topViewControllerWithRootViewController:presentedViewController];
    } else {
        return rootViewController;
    }
}

2017.5.15 更新:

在設置控制器旋轉畫面時,我當前應用中的處理方式:

因為在大多數(shù)場景下,只有少數(shù)頁面是橫屏的,所以基本上是豎屏的,所以我在處理這兩種情況的時候,我比較喜歡使用系統(tǒng)提供的方法:

安卓強制橫屏軟件下載_安卓強制橫屏軟件下載_強制橫屏軟件漢化版

如果你的應用的根控制器是Nav,把下面的代碼放在Nav根控制器下,如果是TabVC,就放在TabVC下

- (BOOL)shouldAutorotate{
    return YES;
}
- (UIInterfaceOrientationMask)supportedInterfaceOrientations{
    return UIInterfaceOrientationMaskPortrait;
}

然后將此代碼添加到您要橫屏的控制器中?;究梢越鉀Q橫屏問題。前提是你的控制器來自 moda。如果是推,則必須使用上述力量。橫豎屏的方法,下面的代碼不起作用

- (BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
    return (toInterfaceOrientation == UIInterfaceOrientationLandscapeRight);
}
- (UIInterfaceOrientationMask)supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskLandscapeRight;
}

第二種解決方案:

靈活設置橫豎屏安卓強制橫屏軟件下載,無需區(qū)分Push與否安卓強制橫屏軟件下載,均可設置。

第一步:

安卓強制橫屏軟件下載_安卓強制橫屏軟件下載_強制橫屏軟件漢化版

在AppDelegate.h中添加旋轉屬性
/**
 * 是否允許轉向
 */
@property(nonatomic,assign)BOOL allowRotation;

在AppDelegate.m中添加轉屏的代理方法
- (UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(nullable UIWindow *)window
{
    
    if (self.allowRotation == YES) {
        //橫屏
        return UIInterfaceOrientationMaskLandscape;
        
    }else{
        //豎屏
        return UIInterfaceOrientationMaskPortrait;
        
    }
    
}

第2步:

設置橫豎屏的核心方法,我直接把這個方法加到里面,代碼如下:

+.h:

#import 
@interface UIDevice (TFDevice)
/**
 * @interfaceOrientation 輸入要強制轉屏的方向
 */
+ (void)switchNewOrientation:(UIInterfaceOrientation)interfaceOrientation;
@end

+.m:

安卓強制橫屏軟件下載_安卓強制橫屏軟件下載_強制橫屏軟件漢化版

#import "UIDevice+TFDevice.h"
@implementation UIDevice (TFDevice)
+ (void)switchNewOrientation:(UIInterfaceOrientation)interfaceOrientation
{
        
        NSNumber *resetOrientationTarget = [NSNumber numberWithInt:UIInterfaceOrientationUnknown];
        
        [[UIDevice currentDevice] setValue:resetOrientationTarget forKey:@"orientation"];
        
        NSNumber *orientationTarget = [NSNumber numberWithInt:interfaceOrientation];
        
        [[UIDevice currentDevice] setValue:orientationTarget forKey:@"orientation"];
    
}
@end

第三步:

在需要設置橫屏的控制器中加入如下代碼:

- (void)viewDidLoad {
    [super viewDidLoad];
    AppDelegate * appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
    //允許轉成橫屏
    appDelegate.allowRotation = YES;
    //調用橫屏代碼
    [UIDevice switchNewOrientation:UIInterfaceOrientationLandscapeRight];
}

第四步(對于推送控制器):

需要注意的是,push過去的時候變成橫屏,pop出來的時候設置豎屏。這時候最好禁用系統(tǒng)的側滑返回手勢。

-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    //禁用側滑手勢方法
    self.navigationController.interactivePopGestureRecognizer.enabled = NO;
}
-(void)viewWillDisappear:(BOOL)animated{
    [super viewWillDisappear:animated];
    //禁用側滑手勢方法
    self.navigationController.interactivePopGestureRecognizer.enabled = YES;
}

強制橫屏軟件漢化版_安卓強制橫屏軟件下載_安卓強制橫屏軟件下載

第五步:

推送控制器:

    //點擊導航欄返回按鈕的時候調用,所以Push出的控制器最好禁用側滑手勢:
     AppDelegate * appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
    appDelegate.allowRotation = NO;//關閉橫屏僅允許豎屏
    //切換到豎屏
    [UIDevice switchNewOrientation:UIInterfaceOrientationPortrait];
        
     [self.navigationController popViewControllerAnimated:YES];

控制器:

    AppDelegate * appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
    appDelegate.allowRotation = NO;//關閉橫屏僅允許豎屏
    //切換到豎屏
    [UIDevice switchNewOrientation:UIInterfaceOrientationPortrait];
    
    [self dismissViewControllerAnimated:YES completion:nil];

第 6 步:

演示地址:

發(fā)表評論

在线日韩网页| 一级看片官网| 2020日韩无码专区视频| 久久久无码久久久中文| 一区二区精品国产| 九九精品久久久| 精品无码在线一区二区| 欧美人与动牲交XXXXBBBB| 无码精品人妻一区二区三区影院| 欧美日本亚洲韩国国产| 亚洲视频免费网站| 国产一级片毛片在线| 老牛影视国产一区二区| 草草家影院| 亚洲精品无码不卡在线播放| av天堂综合自拍| 色欲欧美操女人| 无码专区网站| 天堂久久一区二区| 亚洲区欧美日韩综合| 国产又粗又爽又黄的视频| 96成人动作片| 国产精品一区免费看| 国产精品久久亚洲日韩| 亚洲天堂免费无码| 日韩无码系列| www激情一区久久| 久久综合网hezyo| 特黄一级毛片爽爽影院| 在线看片无码永久免费aⅴ| 色欲亚洲AV无码精品天堂| 白嫩美女网站| AV丝袜一区| 黑人无码精品一区二区三区| 色婷婷av久久久久久久| 粉嫩大学生无套第一次| 日韩九九草视频| 欧美激情xxx黑| 国产乱中文字幕视| 久久精品日韩AV一二区| 国产无码在线播放99|