iOSアプリのレイアウトを回転で変更するとき注意していること

6500a96a5f0786d7ff0c53429d691ae6?s=47 kazuhiro4949
December 28, 2018

 iOSアプリのレイアウトを回転で変更するとき注意していること

6500a96a5f0786d7ff0c53429d691ae6?s=128

kazuhiro4949

December 28, 2018
Tweet

Transcript

  1. J04ΞϓϦͷϨΠΞ΢τΛճసͰ มߋ͢Δͱ͖஫ҙ͍ͯ͠Δ͜ͱ ,B[VIJSP)BZBTIJ /BHPZBJ04NFFUVQWPM

  2. ࣗݾ঺հ wྛ࿨߂ w5XJUUFSɿLB[VIJSP wHJUIVCɿLB[VIJSP wRJJUBɿLB[VIJSP w:BIPP+BQBO$PSQ wJ04ΞϓϦΤϯδχΞ wJ04ΞϓϦࠇଳ

  3. ΞυΧϨͰॻ͍ͨ࿩Λ͠·͢ IUUQTRJJUBDPNLB[VIJSPJUFNTEGGGCBFE

  4. ΞδΣϯμ  ճసڐՄͷઃఆ  ϨΠΞ΢τมߋΛߦ͏λΠϛϯά  ճసͷڧ੍  ಈ࡞֬ೝ

  5. ճసڐՄͷઃఆ

  6. ճసڐՄͷઃఆ  J1IPOFɾJ1BEͰڞ௨ͷ৔߹͸ϓϩδΣΫτϑΝΠϧ  J1IPOFɾJ1BEͰม͑Δ৔߹͸*OGPQMJTU  ը໘ຖʹࡉ͔͘ม͍͑ͨ৔߹͸"QQ%FMFHBUF͔7$  J1IPOF9Ͱ͸6QTJEF%PXO͸Ͱ͖ͳ͍

  7. J1IPOFɾJ1BEͰڞ௨ͷ৔߹ ͸ϓϩδΣΫτϑΝΠϧ

  8. J1IPOFɾJ1BEͰڞ௨ͷ৔߹ ͸ϓϩδΣΫτϑΝΠϧ

  9. J1IPOFɾJ1BEͰڞ௨ͷ৔߹ ͸ϓϩδΣΫτϑΝΠϧ

  10. J1IPOFɾJ1BEͰม͑Δ৔߹ ͸*OGPQMJTU J1BE J1IPOF

  11. ը໘͝ͱʹࡉ͔͘ม͍͑ͨ৔ ߹͸"QQ%FMFHBUF͔7$ "QQ%FMFHBUF಺Ͱͷ࣮૷ func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?)

    -> UIInterfaceOrientationMask { return .all }
  12. ը໘͝ͱʹࡉ͔͘ม͍͑ͨ৔ ߹͸"QQ%FMFHBUF͔7$ 7$಺Ͱͷ࣮૷ override var supportedInterfaceOrientations: UIInterfaceOrientationMask { return .all

    }
  13. J1IPOF9ܥͩͱγεςϜͷઃఆ ͱͯ͠6QTJEF%PXO͕͖͔ͳ͍ w J1IPOF9ܥͰ͸ཪฦͨ͠৔߹ͷճస͸ σόΠεϨϕϧͰޮ͔ͳ͍Α͏ʹͳͬ ͍ͯΔ

  14. ϨΠΞ΢τมߋΛ ߦ͏λΠϛϯά

  15. ϨΠΞ΢τมߋΛ ߦ͏λΠϛϯά override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator)

    { super.viewWillTransition(to: size, with: coordinator) coordinator.animate(alongsideTransition: { _ in if size.width > size.height { // ϨΠΞ΢τมߋॲཧΛॻ͘ } else { // ... } }, completion: nil) } 6*7JFX$POUSPMMFSͷ"1*
  16. ϨΠΞ΢τมߋΛ ߦ͏λΠϛϯά w ઌఔͷճసΠϕϯτ͸ճస͢Δͱଈ࠲ʹݺ͹ΕΔ w 7$͕લ໘ʹ͍ͳ͍৔߹ɺճసͯ͠΋ଈ࠲ʹ͸MBZPVU4VCWJFXT ͳͲ͸ݺ͹Ε ͳ͍ w ճసޙͷϨΠΞ΢τΛ૝ఆͨ͠ܭࢉΛ͜͜΁ॻ͍ͯ͠·͏ͱ่ΕΔ

    w ϨΠΞ΢τॲཧ͸ϨΠΞ΢τΠϕϯτ಺Ͱ࣮૷ͨ͠΄͏͕͍͍
  17. ճసͷڧ੍

  18. ճసͷڧ੍ w σόΠεͷճసΛڲਖ਼͢Δ"1*͸ͳ͍ w 7$͝ͱͷճసΛ࢖ٖͬͯࣅతʹߦ͏

  19. ճసͷڧ੍ override var preferredInterfaceOrientationForPresentation: UIInterfaceOrientation { return .landscapeRight } 6*7JFX$POUSPMMFSͷ"1*

    ͜ΕͰϞʔμϧ͕දࣔ͞ΕΔํ޲ΛܾΊΒΕΔɻ ͜ͷઃఆͩͱɺࠨ͔Βӈʹ޲͔ͬͯϞʔμϧ͕಄Λग़ͯ͘͠Δ
  20. ճసͷڧ੍ 6*7JFX$POUSPMMFSͷ"1* ͜ΕͰσόΠεΛճͯ͠΋7$͸-BOETDBQF3JHIUͷ··ʹͳΔ override var supportedInterfaceOrientations: UIInterfaceOrientationMask { return .landscapeRight

    } override var shouldAutorotate: Bool { return false }
  21. ճసͷڧ੍ w ը໘͕ճస͢ΔΑ͏ͳΧελϜτϥϯδγϣϯΛ࣮૷ w σόΠε͕ճస͍ͯ͠ΔΑ͏ʹݟͤΒΕΔ w /PUJpDBUJPO$FOUFSͰPSJFOUBUJPO%JE$IBOHF/PUJpDBUJPOΛ؂ࢹ w σόΠεͷճసʹ߹ΘͤͯϞʔμϧΛදࣔͤ͞ΒΕΔ

  22. ճసͷڧ੍ UIDevice.current.setValue( UIInterfaceOrientation.landscapeRight.rawValue, forKey: “orientation” ) Ωʔ஋ίʔσΟϯάͰϓϥΠϕʔτ"1*Λୟ͚͹ σόΠεճస͕Ͱ͖Δ

  23. ಈ࡞֬ೝ

  24. ಈ࡞֬ೝ w ճస͸7$͕Ͳͷ֊૚ʹ͍ͯ΋࣮ߦ͞ΕΔ w ϨΠΞ΢τ͸7$ͷ֊૚্ͷҐஔ΍දࣔͷ͞ΕํͰ࣮ߦ͞Εͳ͍ࣄ͕͋Δ

  25. ಈ࡞֬ೝ w ैͬͯɺલ໘ʹݟ͍͑ͯΔͱ͖ͷϨΠΞ΢τ͚ͩ֬ೝ͢Ε͹͍͍Θ͚Ͱ͸ͳ͍ w φϏήʔγϣϯͷதʹӅΕ͍ͯΔͱ͖ͳͲͰճసͷϝιου͕ݺ͹Εͨ৔߹ͷ ςετ΋͓͍ͯͨ͠΄͏͕͍͍

  26. Ҏ্ɺͭͷ؍఺Ͱ·ͱΊͯΈ·ͨ͠  ճసڐՄͷઃఆ  ϨΠΞ΢τมߋΛߦ͏λΠϛϯά  ճసͷڧ੍  ಈ࡞֬ೝ