如果用戶將iPad保持橫向模式,我正在確定鍵盤的幀偏移量。如果我在橫向模式下添加內容,然後將iPad平放在表面上,我發現無法正確設置偏移量。我使用下面的代碼來設置偏移:在設備已放置在表面上後,是否可以找出應用UI是否處於橫向方向?
if ([[UIDevice currentDevice] orientation] == UIDeviceOrientationLandscapeLeft || [[UIDevice currentDevice] orientation] == UIDeviceOrientationLandscapeRight) {
tableView.frame = CGRectMake(0,0,tableView.frame.size.width, tableView.frame.size.height-keyboardsize.height);
}
UIDeviceOrientations,我可以檢查有:
typedef enum {
UIDeviceOrientationUnknown,
UIDeviceOrientationPortrait,
UIDeviceOrientationPortraitUpsideDown,
UIDeviceOrientationLandscapeLeft,
UIDeviceOrientationLandscapeRight,
UIDeviceOrientationFaceUp,
UIDeviceOrientationFaceDown
} UIDeviceOrientation;
有什麼辦法,我檢查/知道用戶是否以橫向方向持有應用程序(UIDeviceOrientationLandscapeLeft
或UIDeviceOrientationLandscapeRight
),然後將設備放下(應該是UIDeviceOrientationFaceUp
)
這解決了我的問題,謝謝! – propstm