0

iOS8用のカスタムキーボードを構築しています。縦向きモードと横向きモードをサポートするキーボードが必要です。デバイスの向きを確認するにはどうすればよいですか? デバイスの向きの取得は、現在、カスタム キーボードではうまく機能しません。

4

3 に答える 3

1

willRotateToInterfaceOrientationdidRotateFromInterfaceOrientationを使用できますが、iOS 8 では廃止されてwillTransitionToTraitCollectionいます。キーボードの特性コレクションが変更されない可能性が高いため、それらの代替である はローテーション時に呼び出されません。

于 2014-11-15T05:08:55.417 に答える
0

このアプローチを使用できます。

typedef NS_ENUM(NSInteger, InterfaceOrientationType)
{
    InterfaceOrientationTypePortrait,
    InterfaceOrientationTypeLandscape
};

- (InterfaceOrientationType)orientation
{
    InterfaceOrientationType result;

    if([UIScreen mainScreen].bounds.size.width < [UIScreen mainScreen].bounds.size.height)
    {
        result = InterfaceOrientationTypePortrait;
    }
    else
    {
        result = InterfaceOrientationTypeLandscape;
    }

    return result;
}
于 2014-11-07T16:32:28.743 に答える