第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

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

如何以編程方式確定iPhone界面方向?

如何以編程方式確定iPhone界面方向?

夢里花落0921 2019-08-02 16:37:56
如何以編程方式確定iPhone界面方向?UIDevice.orientationinclude UIDeviceOrientationFaceUp和 的可能值UIDeviceOrientationFaceDown。雖然知道設(shè)備是扁平的可能是有用的,但這并不能告訴我們它是否是平面顯示面向縱向或橫向模式的界面。有沒有辦法在設(shè)備返回模糊信息的情況下找到GUI的當前方向?我想我可以跟蹤方向變化事件以記住最后的縱向/橫向方向或檢查主要UIView的邊界高度和寬度,但這似乎是kludgey。設(shè)備或UIView上有一個我失蹤的財產(chǎn)嗎?
查看完整描述

3 回答

?
慕工程0101907

TA貢獻1887條經(jīng)驗 獲得超5個贊

您可以通過3種方式獲得方向:

  1. UIInterfaceOrientation orientation = self.interfaceOrientation; 返回UIInterfaceOrientation,接口的當前方向。它是UIViewController中的一個屬性,只能在UIViewController類中訪問它。

  2. UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation]; 返回UIInterfaceOrientation,即應(yīng)用程序狀態(tài)欄的當前方向。您可以在應(yīng)用程序的任何位置訪問該屬性。我的經(jīng)驗表明,這是檢索真實界面方向的最有效方法。

  3. UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation];返回UIDeviceOrientation,設(shè)備方向。您可以在應(yīng)用程序的任何位置訪問該屬性。但請注意,UIDeviceOrientation并不總是UIInterfaceOrientation。例如,當您的設(shè)備位于普通表上時,您可以獲得意外的價值。


查看完整回答
反對 回復(fù) 2019-08-02
?
至尊寶的傳說

TA貢獻1789條經(jīng)驗 獲得超10個贊

如果您只是關(guān)心設(shè)備是橫向還是縱向,那么viewcontroller上有一些不錯的便利方法:

UIDeviceOrientationIsLandscape(self.interfaceOrientation)
UIDeviceOrientationIsPortrait(self.interfaceOrientation)


查看完整回答
反對 回復(fù) 2019-08-02
?
函數(shù)式編程

TA貢獻1807條經(jīng)驗 獲得超9個贊

在viewcontroller中,您只需使用代碼:

UIInterfaceOrientation interfaceOrientation = self.interfaceOrientation;

UIInterfaceOrientation是一個枚舉:

typedef enum {
  UIInterfaceOrientationPortrait           = UIDeviceOrientationPortrait,
  UIInterfaceOrientationPortraitUpsideDown = UIDeviceOrientationPortraitUpsideDown,
  UIInterfaceOrientationLandscapeLeft      = UIDeviceOrientationLandscapeLeft,
  UIInterfaceOrientationLandscapeRight     = UIDeviceOrientationLandscapeRight} UIInterfaceOrientation;


查看完整回答
反對 回復(fù) 2019-08-02
  • 3 回答
  • 0 關(guān)注
  • 566 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號