Richtlinie
Tutorial zur Bildschirmorientierung
Mit @capgo/capacitor-screen-orientation
Capacitor Schnittstelle für die Bildschirmorientierung
Installieren
bun add @capgo/capacitor-screen-orientation
bunx cap sync
Was diese Erweiterung offenlegt
orientation- Ermitteln Sie die aktuelle Bildschirmorientierung.lock- Sperren Sie die Bildschirmorientierung auf eine bestimmte Art.unlock- Entschlüsseln Sie die Bildschirmorientierung.startOrientationTracking- Starten Sie das Tracking der Geräteorientierung mithilfe von Bewegungssensoren.
Beispiel für die Verwendung
orientation
Ermitteln Sie die aktuelle Bildschirmorientierung.
import { ScreenOrientation } from '@capgo/capacitor-screen-orientation';
const result = await ScreenOrientation.orientation();
console.log('Current orientation:', result.type);
lock
Sperren Sie die Bildschirmorientierung auf eine bestimmte Art.
import { ScreenOrientation } from '@capgo/capacitor-screen-orientation';
// Standard lock
await ScreenOrientation.lock({ orientation: 'landscape' });
// Lock with motion tracking on iOS
await ScreenOrientation.lock({
orientation: 'portrait',
bypassOrientationLock: true
});
unlock
Entschlüsseln Sie die Bildschirmorientierung.
import { ScreenOrientation } from '@capgo/capacitor-screen-orientation';
await ScreenOrientation.unlock();
startOrientationTracking
Starten Sie das Tracking der Geräteorientierung mithilfe von Bewegungssensoren.
import { ScreenOrientation } from '@capgo/capacitor-screen-orientation';
await ScreenOrientation.startOrientationTracking({
bypassOrientationLock: true
});
// Listen for changes
ScreenOrientation.addListener('screenOrientationChange', (result) => {
console.log('Orientation changed:', result.type);
});
Vollständige Referenz
- GitHub: https://github.com/Cap-go/capacitor-Bildschirmorientierung/
- Dokumentation: /docs/plugins/Bildschirmorientierung/
Weitermachen von Using @capgo/capacitor-Bildschirmorientierung
Wenn Sie Using verwenden Mit @capgo/capacitor-Bildschirmorientierung um native Medien und Schnittstellenverhalten zu planen, verbinden Sie es mit @capgo/capacitor-Bildschirmorientierung für die Implementierungsdetails in @capgo/capacitor-Bildschirmorientierung, Einstieg für die Implementierungsdetails in Einstieg, Mit @capgo/capacitor-live-Aktivitäten für die native Fähigkeit in Using @capgo/capacitor-live-activities @capgo/capacitor-live-activities für die Implementierungsdetail in @capgo/capacitor-live-activities, und Mit @capgo/capacitor-video-player für die native Fähigkeit in Mit @capgo/capacitor-video-player.