Screen.setOrientation
函数式 API
setDeviceOrientation也可以这样使用同样的功能。
功能说明
设置设备屏幕方向。用于在特定屏幕上强制横屏/竖屏模式时很有用。
会影响整个应用,因此如果只在特定屏幕上使用,请在离开该屏幕时恢复到之前的状态。
Toss App Android/iOS 5.215.0 可在以上版本使用。若在不支持的版本中调用则 UNSUPPORTED_APP_VERSION 会发生错误。
类型
Screen.setOrientation(options: SetDeviceOrientationOptions): Promise<void>;Params
type DeviceOrientation = "portrait" | "landscape";
interface SetDeviceOrientationOptions {
type: DeviceOrientation;
}Response
无。
错误代码
错误代码是 catch 到的错误的 error.code 值。
代码
说明
UNSUPPORTED_APP_VERSION
如果当前运行的 Toss App 版本不支持此功能,调用后会立即发生。 Screen.setOrientation.isSupported()可通过它提前确认,发生时 error.message请向用户显示(更新提示文案)。
示例代码
这有帮助吗?