亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

在iOS6中,將ViewController推入堆棧時強制將ViewController強制為特定

在iOS6中,將ViewController推入堆棧時強制將ViewController強制為特定

iOS
至尊寶的傳說 2019-11-20 10:04:31
我設置了以下視圖控制器:viewController1可以自由旋轉到除了人像倒置之外的任何方向。viewController2被推到viewController1的頂部,我希望它與viewController1的方向相同,并且我希望它不能旋轉。viewController3被推到viewController2的頂部。我希望viewController3處于縱向模式。我在嘗試在iOS6中完成此操作時遇到了很多問題(在iOS5中尚未嘗試過)。首先,我已經創建了自己的導航控制器,并將以下內容放入其中:- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation{    return [self.topViewController preferredInterfaceOrientationForPresentation];}- (NSUInteger)supportedInterfaceOrientations{    return [self.topViewController supportedInterfaceOrientations];}- (BOOL) shouldAutorotate{    return [self.topViewController shouldAutorotate];}我嘗試了這些東西的許多不同組合,以了解是否有用。如果vc2是橫向的,我主要是在強迫vc3以縱向顯示。任何幫助,將不勝感激。
查看完整描述

3 回答

?
隔江千里

TA貢獻1906條經驗 獲得超10個贊

- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window

{

if ([self.window.rootViewController.presentedViewController isKindOfClass: [SecondViewController class]])

{

    SecondViewController *secondController = (SecondViewController *) self.window.rootViewController.presentedViewController;


    if (secondController.isPresented)

        return UIInterfaceOrientationMaskAll;

    else return UIInterfaceOrientationMaskPortrait;

}

else return UIInterfaceOrientationMaskPortrait;

}

對于斯威夫特


func application(application: UIApplication, supportedInterfaceOrientationsForWindow window: UIWindow) -> Int {


    if self.window?.rootViewController?.presentedViewController? is SecondViewController {


        let secondController = self.window!.rootViewController.presentedViewController as SecondViewController


        if secondController.isPresented {

            return Int(UIInterfaceOrientationMask.All.toRaw());

        } else {

            return Int(UIInterfaceOrientationMask.Portrait.toRaw());

        }

    } else {

        return Int(UIInterfaceOrientationMask.Portrait.toRaw());

    }


}


查看完整回答
反對 回復 2019-11-20
  • 3 回答
  • 0 關注
  • 635 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號