カスタムキーボードで端末の向きを判定するTIPS
カスタムキーボード内ではUIDevice のorientation の値がうまく使えないため、ちょっと工夫が必要。
isPortrait
// 端末の向き判定
-(BOOL)isPortrait{
return ([UIScreen mainScreen].bounds.size.width < [UIScreen mainScreen].bounds.size.height);
}
上記メソッドをUIInputViewController を継承したクラス内に追加すれば端末の状態の判定が可能。
参考:How to detect Orientation Change in Custom Keyboard Extension in iOS 8?