0
我在UIWindow中添加了兩個視圖控制器作爲子視圖。現在問題是視圖獲取視圖旋轉調用之一,但其次是沒有調用視圖改變方向的調用。 現在我的問題是我們如何獲得在UIWindow中添加的兩個不同視圖控制器的更改方向調用。爲UIResponder添加兩個監聽器
我在UIWindow中添加了兩個視圖控制器作爲子視圖。現在問題是視圖獲取視圖旋轉調用之一,但其次是沒有調用視圖改變方向的調用。 現在我的問題是我們如何獲得在UIWindow中添加的兩個不同視圖控制器的更改方向調用。爲UIResponder添加兩個監聽器
UIWindow
只發送旋轉消息發送到其rootViewController
。如果你想在其他視圖控制器接收他們,你有兩個選擇:
rootViewController
送轉消息到其他視圖控制器。註冊設備的方向。
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(detectOrientation) name:@"UIDeviceOrientationDidChangeNotification" object:nil];
檢查的方法,
if (([[UIDevice currentDevice] orientation] == UIDeviceOrientationLandscapeLeft) ||
([[UIDevice currentDevice] orientation] == UIDeviceOrientationLandscapeRight)) {
}
我怎麼能送轉呼叫,我不寫代碼來旋轉視圖這樣的方式來視圖控制器(指自動調整大小屬性的作品)。我不想旋轉視圖使用CGAffineTransform – 2012-02-17 07:28:37
如果您使您的視圖爲'UIWindow'的子視圖,則必須使用'CGAffineTransform'。 'UIWindow'爲你設置'rootViewController.view'的轉換。如果您將其他子視圖添加到窗口中,則必須自己設置其轉換。 – 2012-02-17 08:01:03
您可能會發現使窗口的單個子視圖更簡單,並使第二個視圖控制器的視圖成爲該視圖的子視圖。 – 2012-02-17 08:01:30