This page references our older Objective-C SDK. Check out our new Swift SDK to integrate our latest Swift-first library.
向きのカスタマイズ
すべてのアプリ内メッセージの向きの設定
すべてのアプリ内メッセージの向きを固定するには、ABKInAppMessageUIController
で supportedOrientationMask
プロパティを設定します。アプリが startWithApiKey:inApplication:withLaunchOptions:
を呼び出した後に、次のコードを追加します。
1
2
3
4
// Set fixed in-app message orientation to portrait.
// Use UIInterfaceOrientationMaskLandscape to display in-app messages in landscape
id<ABKInAppMessageUIControlling> inAppMessageUIController = [Appboy sharedInstance].inAppMessageController.inAppMessageUIController;
((ABKInAppMessageUIController *)inAppMessageUIController).supportedOrientationMask = UIInterfaceOrientationMaskPortrait;
1
2
3
4
5
// Set fixed in-app message orientation to portrait
// Use .landscape to display in-app messages in landscape
if let controller = Appboy.sharedInstance()?.inAppMessageController.inAppMessageUIController as? ABKInAppMessageUIController {
controller.supportedOrientationMask = .portrait
}
その後、すべてのアプリ内メッセージは、デバイスの向きに関係なく、サポートされている向きで表示されます。メッセージを表示するには、デバイスの向きがアプリ内メッセージの orientation
プロパティでもサポートされている必要があることに注意してください。
アプリ内メッセージごとの向きの設定
または、メッセージごとに方向を設定することもできます。これを行うには、アプリ内メッセージデリゲートを設定します。次に、beforeInAppMessageDisplayed:
デリゲートメソッドで、ABKInAppMessage
の orientation
プロパティを設定します。
```objc //アプリ内メッセージの向きを縦向きに設定 inAppMessage.orientation = ABKInAppMessageOrientationPortrait;
//アプリ内メッセージの向きを横向きに設定 inAppMessage.orientation = ABKInAppMessageOrientationLandscape; ```
```swift
//アプリ内メッセージの向きを縦向きに設定
inAppMessage.orientation = ABKInAppMessageOrientation.portrait
//アプリ内メッセージの向きを横向きに設定 inAppMessage.orientation = ABKInAppMessageOrientation.landscape ```
orientation
デバイスの向きがアプリ内メッセージのプロパティと一致しない場合、アプリ内メッセージは表示されません。
iPad の場合、アプリ内メッセージは、実際の画面の向きに関係なく、ユーザーが希望する向きのスタイルで表示されます。
メソッド宣言
追加情報については、次のヘッダーファイルを参照してください。