[英]setAutoresizeMask does not work when Orientation changes on iPad
[英]When does it changes orientation to default orientation?
我正在使用最新的SDK開發iOS應用程序。
我的應用僅支持橫向右對齊,並且只有一個視圖控制器。 我設置了修改myProject-info.plist
的唯一可用方向。
我想了解為什么當我僅支持橫向右方向時,此代碼為何在縱向模式下為視圖輸出日志。
- (void) viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation;
UIView *videoView = self.videoPreviewView;
NSLog(@"Video frame: %@", NSStringFromCGRect(videoView.frame));
}
控制台輸出:
Video frame: {{0, 0}, {320, 568}}
我正在使用AVCaptureVideoPreviewLayer
並需要設置其框架,但是當我在viewWillAppear:
上進行設置時viewWillAppear:
我獲得了肖像值,但orientation
值正確為Landscape。
方向更改為景觀時是否會觸發事件或類似事件?
該應用程序何時將方向更改為默認方向?
進入xCode,然后單擊屏幕頂部的項目名稱(在其下方帶有xcode LOGO)。 然后顯示iPhone / Ipad的開發信息,並選擇您想為用戶使用的方向:)
如果添加行:
[[NSNotificationCenter defaultCenter] addObserver:自我選擇器:@selector(orientationChanged)名稱:UIDeviceOrientationDidChangeNotification對象:無];
然后它將調用-(void)orientationChanged;
每次改變方向的方法。 然后,您可以執行以下操作:
-(void)orientationChanged {
if (UIDeviceOrientationIsPortrait([UIApplication sharedApplication].statusBarOrientation) {
//device is portrait;
}
else {
//device is landscape;
}
}
然后,您可以使用它來確定視圖的布局和基於方向的設置。
編輯:您還可以檢查statusBar的方向返回的方向是否等於UIDeviceOrientationLandscapeLeft / LandscapeRight / Portrait / PortraitUpsideDown。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.