Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

290
Views
Ionic 2: orientación horizontal habilitada solo para iPad

Puedo establecer la orientación en modo vertical únicamente en config.xml de la siguiente manera:

 <preference name="Orientation" value="portrait"/>

Pero, ¿cómo puedo permitir la orientación horizontal para las compilaciones de iPad, mientras sigo deshabilitando para iPhone como se indicó anteriormente?

about 4 years ago · Santiago Trujillo
2 answers
Answer question

0

Según Mike Harrison de Ionic, dice:

Aparte de rotar manualmente el dispositivo, en realidad no. Esto sería algo para lo que escribiría un complemento para modificar la vista principal de la aplicación en cordova

Pero hay un complemento de Ionic 1 . Míralo. Eventualmente, también puedes usarlo en Ionic 2.

Con este complemento podrías hacer algo como:

 if(/(ipad)/i.test(navigator.userAgent)) { //THIS IS THE PLUGIN IONIC 1 CODE $scope.changeOriantationPortrait = function() { screen.lockOrientation('portrait'); } }
about 4 years ago · Santiago Trujillo Report

0

Puede eliminar una preferencia de config.xml y definirla a través de un complemento nativo Orientación de pantalla

Luego, en app.component.ts bloqueo de orientación para teléfonos:

 // check if platform is not a tablet if (platform.is('cordova') && !platform.is('tablet')) { // lock orientation to only portrait mode this.screenOrientation.lock(this.screenOrientation.ORIENTATIONS.PORTRAIT); // set screen orientation to 'portrait' globalProvier.screenOrientation = this.screenOrientation.ORIENTATIONS.PORTRAIT; } else { // if it's tablet // set device type to 'tablet' globalProvier.deviceType = platform.platforms()[3]; // set current orientation type ('portrait-primary' or 'landscape-primary' or 'portrait-secondary' or landscape-secondary) globalProvier.screenOrientation = this.screenOrientation.type; // set listener on changing orientation this.screenOrientation.onChange().subscribe( () => { globalProvier.screenOrientation = this.screenOrientation.type; console.log("Orientation Changed to: ", this.screenOrientation.type); } ); }

Ahora puede ajustar dinámicamente su diseño dependiendo de las orientaciones de la tableta con la variable globalProvier.screenOrientation . Agregue clases o use *ngIf en las plantillas.

 *ngIf='this.globalProvider.screenOrientation == "landscape-primary" || <h3 *ngIf='this.globalProvider.screenOrientation == "landscape-primary" || this.globalProvider.screenOrientation == "landscape-secondary"'>Orientation: landscape</h3>
about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!