Anleitung
Tutorial zur Bildschirmorientierung
Mit @capgo/capacitor-screen-orientation
Capacitor Bildschirmorientierung-Plugin-Schnittstelle.
Installieren
bun add @capgo/capacitor-screen-orientation
bunx cap sync
Was dieses Plugin bereitstellt
orientation- Ermitteln Sie die aktuelle Bildschirmorientierung.lock- Sperren Sie die Bildschirmorientierung auf eine bestimmte Art.unlock- Entschlüsseln Sie die Bildschirmorientierung.startOrientationTracking- Starten Sie die Verfolgung der Geräteorientierung mithilfe von Bewegungssensoren.
Beispielhafte 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
Die Bildschirmorientierung auf eine bestimmte Art festlegen.
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
Die Bildschirmorientierung freigeben.
import { ScreenOrientation } from '@capgo/capacitor-screen-orientation';
await ScreenOrientation.unlock();
startOrientationTracking
Mit Hilfe von Bewegungssensoren die Geräteorientierung verfolgen.
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 Using @capgo/capacitor-Bildschirmorientierung um native Medien und Schnittstellenverhalten zu planen, verbinden Sie es mit @capgo/capacitor-Bildschirmorientierung zur Implementierungsdetail in @capgo/capacitor-Orientierung des Bildschirms, Anfänger zur Implementierungsdetail in Anfänger, Verwendung von @capgo/capacitor-live-Aktivitäten zur nativen Fähigkeit in Verwendung von @capgo/capacitor-live-Aktivitäten, @capgo/capacitor-live-Aktivitäten zur Implementierungsdetail in @capgo/capacitor-live-Aktivitäten und Verwendung von @capgo/capacitor-Video-Player zur nativen Fähigkeit in Verwendung von @capgo/capacitor-Video-Player.