Save 37% off PRO during our Black Friday Sale! »

20170613_iOSLT_UIKitにおけるViewLifecycle

 20170613_iOSLT_UIKitにおけるViewLifecycle

E45f9c343d90c74554c65c89c6f861bc?s=128

shtnkgm

June 13, 2017
Tweet

Transcript

  1. 6*,JUʹ͓͚Δ 7JFX-JGFDZDMF  4IPUB/BLBHBNJ!TIUOLHN

  2. 6*࣮૷࣌ͷΑ͋͘Δ՝୊ w ͳΜ͔εΫϩʔϧ͕ΧΫΧΫ͢ΔɺҾ͔͔ͬΔ w "VUP-BZPVU͕ޮ͔ͳ͍ w 7JFXͷදࣔҐஔ͕͓͔͍͠ɺදࣔ͞Εͳ͍ w ը໘දࣔ·Ͱ͕஗͍

  3. Α͋͘Δσόοά w 6*ߋ৽ΛαϒεϨου͔ΒϝΠϯεϨουʹมߋ
 ʢ௨৴ॲཧͷίʔϧόοΫ௨஌಺ͳͲʣ
 㱺9DPEFͰ͸.BJO5ISFBE$IFDLFSͰ
 νΣοΫՄ w Կ͔Α͘Θ͔Βͳ͍͚ͲɺMBZPVU*G/FFEFEͱ͔ॻ ͍ͨΒ௚Δ

  4. 6*,JUͰͷ7JFXͷ
 දࣔॲཧʹؔ͢Δ஌͕ࣝඞཁ

  5. 7JFX-JGFDZDMFʹؔ͢Δϝιου VQEBUF$POTUSBJOUT*G/FFEFE TFU/FFET-BZPVU VQEBUF$POTUSBJOUT TFU/FFET6QEBUF$POTUSBJOUT MBZPVU4VCWJFXT ESBX TFU/FFET%JTQMBZ MBZPVU*G/FFEFE WJFX%JE-PBE

    MPBE7JFX WJFX8JMM"QQFBS VQEBUF7JFX$POTUSBJOUT WJFX8JMM-BZPVU4VCWJFXT WJFX%JE-BZPVU4VCWJFXT
  6. ଟ͍ʂʘ ?P? ʗ

  7. େ·͔ͳྲྀΕ w 7JFXͷಡΈࠐΈ w ੍໿ͷ௥Ճʢ"VUP-BZPVUʣ w ੍໿Λݩʹ7JFXͷGSBNFΛܭࢉʢϨΠΞ΢τʣ w GSBNFͷҐஔʹඳըʢϨϯμϦϯάʣ

  8. αϯϓϧϓϩδΣΫτ Λͭͬͯ͘ॲཧΛ௥ͬͯΈΔ IUUQTHJUIVCDPNTIUOLHN7JFX-JGFDZDMF4BNQMF

  9. ̏ຕϏϡʔΛॏͶ͚ͨͩ ʢΧελϜ6*7JFXʣ ԼͷϏϡʔ͔Βॱʹ ɾ8IJUF7JFX
 ʢTFMGWJFXʣ ɾ3FE7JFX
 ʢ8IJUF7JFXͷTVCWJFXʣ ɾ#MVF7JFX
 ʢ3FE7JFXͷTVCWJFXʣ

  10. Ϋϥε໊ͱϝιου໊Λ
 ֤ϝιουݺͼग़࣌͠ʹϩάग़ྗ

  11. 7JFXͷදࣔ·Ͱͷ ϩάग़ྗ݁Ռ

  12. ඳը ϨΠΞ΢τ ੍໿ߋ৽ ϏϡʔͷಡΈࠐΈ

  13. ֤ϝιουͷઆ໌ 6*7JFX

  14. ੍໿ͷߋ৽ʹؔ͢Δϝιου w VQEBUF$POTUSBJOUT 
 ੍໿ͷߋ৽Λ࣮ߦ
 ։ൃऀ͕௚઀ݺͼग़͢ͷ͸/( w TFU/FFET6QEBUF$POTUSBJOUT 
 ੍໿ߋ৽ͷ࣮ߦཁ൱ͷϑϥάΛཱͯΔ


    ܭࢉ࣮ߦλΠϛϯά͸γεςϜ೚ͤ w VQEBUF$POTUSBJOUT*G/FFEFE 
 ੍໿ߋ৽Λଈ࠲ʹ࣮ߦʢߋ৽ϑϥά͋Ε͹ʣ
  15. ύϑΥʔϚϯεͷྑ͍ॱ w PWFSSJEFͨ͠VQEBUF$POTUSBJOUT ಺Ͱ੍໿ߋ৽
 ʢϨΠΞ΢τΤϯδϯͷόονॲཧʹؚ·Εɺϝ ΠϯεϨουΛϒϩοΫ͠ͳ͍ʣ w ੍໿ߋ৽ޙʹTFU/FFET6QEBUF$POTUSBJOUT 
 ʢΤϯδϯ͕·ͱΊͯߋ৽ॲཧΛ࣮ࢪʣ

    w ੍໿ߋ৽ޙʹVQEBUF$POTUSBJOUT*G/FFEFE 
 ʢଈ࣮࣌ߦͷͨΊɺόονॲཧʹؚ·Εͳ͍ʣ
  16. ϨΠΞ΢τʹؔ͢Δϝιου w MBZPVU4VCWJFXT 
 GSBNFͷߋ৽Λ࣮ߦ
 ։ൃऀ͕௚઀ݺͼग़͢ͷ͸/( w TFU/FFET-BZPVU 
 GSBNFߋ৽ཁ൱ͷϑϥάΛཱͯΔ


    ܭࢉ࣮ߦλΠϛϯά͸γεςϜ೚ͤ w MBZPVU*G/FFEFE 
 GSBNFߋ৽Λଈ࠲ʹ࣮ߦʢߋ৽ϑϥά͋Ε͹ʣ
  17. ύϑΥʔϚϯεͷྑ͍ॱ w PWFSSJEFͨ͠MBZPVU4VCWJFXT ಺ͰGSBNFߋ৽
 ʢϨΠΞ΢τΤϯδϯͷόονॲཧʹؚ·Εɺ ϝΠϯεϨουΛϒϩοΫ͠ͳ͍ʣ w GSBNFߋ৽ޙʹTFU/FFET-BZPVU 
 ʢΤϯδϯ͕·ͱΊͯߋ৽ॲཧΛ࣮ࢪʣ

    w GSBNFߋ৽ޙʹMBZPVU*G/FFEFE 
 ʢଈ࣮࣌ߦͷͨΊɺόονॲཧʹؚ·Εͳ͍ʣ
  18. ඳըʹؔ͢Δϝιου w ESBX 
 ։ൃऀ͕௚઀ݺͼग़ͯ͠͸͍͚ͳ͍
 $PSF(SBQIJDTΛ࢖ͬͯը໘ʹඳը͢Δ w TFU/FFET%JTQMBZ 
 ඳըߋ৽ͷ࣮ߦཁ൱ͷϑϥάΛཱͯΔ

    w ੍໿΍ϨΠΞ΢τߋ৽ͷΑ͏ʹɺ
 ଈ࣮࣌ߦ༻ͷϝιου͸ͳ͠
  19. Ϗϡʔ֊૚ͱ࣮ߦॱং w ੍໿͸ࢠ7JFX͔Β w ϨΠΞ΢τ͸਌7JFX͔ Β

  20. ͜͜·Ͱͷ·ͱΊʢ7JFXʣ w ੍໿
 VQEBUF$POTUSBJOUT ύϑΥʔϚϯε͕ඞཁͳ৔߹౳ͳͲʹPWFSSJEF͢Δ
 TFU/FFET6QEBUF$POTUSBJOUT ߋ৽ϑϥά
 VQEBUF$POTUSBJOUT*G/FFEFE ଈ࣌ߋ৽ w

    ϨΠΞ΢τ
 MBZPVU4VCWJFXT ύϑΥʔϚϯε͕ඞཁͳ৔߹ͳͲʹPWFSSJEF͢Δ
 TFU/FFET-BZPVU ߋ৽ϑϥά
 MBZPVU*G/FFEFE ଈ࣌ߋ৽ w ඳը
 ESBX ύϑΥʔϚϯε͕ඞཁͳ৔߹ͳͲʹPWFSSJEF͢Δ
 TFU/FFET%JTQMBZ ߋ৽ϑϥά
  21. ֤ϝιουͷઆ໌ 6*7JFX$POUSPMMFS

  22. MPBE7JFX w ؅ཧ͢Δ7JFXΛಡΈࠐΉʢTFMGWJFXʣ w 4UPSZ#PBSEͰ࣮૷͢Δ৔߹͸PWFSSJEFෆཁ

  23. WJFX%JE-PBE w MPBE7JFX ͕׬ྃͨ͠ࡍʹݺ͹ΕΔ w 7$ͷදࣔαΠΫϧͰҰ౓͚ͩݺ͹ΕΔͨΊɺ
 Ϋϥε಺Ͱར༻͢ΔΦϒδΣΫτͷॳظԽͳͲʹద͢Δ

  24. WJFX8JMM"QQFS w Ϗϡʔ͕දࣔ͞ΕΔ௚લʹݺ͹ΕΔ w ॳճදࣔҎ֎ʹ΋όοΫάϥ΢ϯυ෮ؼɺλϒ ੾Γସ͑ͳͲ

  25. VQEBUF7JFX$POTUSBJOUT w αϒϏϡʔͷ੍໿ߋ৽ޙɺTFMGWJFXͷ੍໿ߋ৽ ͕ඞཁͳࡍʹݺ͹ΕΔ w TFMGWJFXͷVQEBUF$POTUSBJOUT ͕ݺ͹ΕΔ w PWFSSJEFͰͷར༻༻్͸͋·Γͳ͠ʁ

  26. WJFX8JMM-BZPVU4VCWJFXT w ϏϡʔͷϨΠΞ΢τΛ։࢝͢Δ௚લʹݺ͹ΕΔ
 ʢॳظදࣔ࣌΍ը໘ճస࣌ͳͲʣ w ϏϡʔͷMBZPVU4VCWJFX ͕࣮ߦ͞ΕΔ

  27. WJFX%JE-BZPVU4VCWJFXT w ϏϡʔͷϨΠΞ΢τ͕׬ྃͨ͠ࡍʹݺ͹ΕΔ
 ʢෳ਺ճݺ͹ΕΔͷͰɺΦϒδΣΫτͷॳظԽͳͲ ʹ͸޲͔ͳ͍ʣ w TFMGWJFXGSBNF͸͜ͷϝιουΑΓ΋લͩͱ֬ఆ͠ ͍ͯͳ͍ w WJFX%JE-PBE

    ͳͲͰTFMGWJFXGSBNFΛ༻͍ͯϨΠ Ξ΢τ͢Δͱҙਤ͢ΔϨΠΞ΢τͱͳΒͳ͍Մೳੑ ͋Γ
  28. WJFX%JE"QQFS w Ϗϡʔ͕දࣔ͞Εͨ௚ޙʹݺ͹ΕΔ w WJFX8JMM"QQFS ಉ༷ɺόοΫάϥ΢ϯυ෮ؼ࣌ ΍λϒ੾Γସ͑࣌ͳͲෳ਺ճݺ͹ΕΔ w طʹ6*ද͕ࣔ׬͍ྃͯ͠ΔͷͰɺ6*දࣔʹؔ܎ ͷͳ͍ॲཧΛ࣮ߦ͢Δͷʹద͢Δʢϩάૹ৴ͳ

    Ͳʣ
  29. ͜͜·Ͱͷ·ͱΊʢ7$ʣ w WJFX%JE-BZPVU4VCWJFXT ͷ࣮ߦ·Ͱ͸GSBNF ͕֬ఆ͍ͯ͠ͳ͍ͨΊɺ஫ҙ͕ඞཁ w WJFX͕දࣔ͞ΕΔɺWJFX%JE"QQFS ͷ࣮ߦ·Ͱ ͸6*ؔ࿈Ҏ֎Ͱͷίετͷ͔͔Δॲཧ͸ͳΔ΂ ͘͠ͳ͍


  30. "QQFOEJY

  31. 2੍໿Λߋ৽ͨ͠ΒͲ͏ͳΔʁ w ੺͍Ϗϡʔͱ੨͍Ϗϡʔͷ੍໿Λߋ৽ w ؔ࿈͢Δ਌ϏϡʔͷTFU/FFET-BZPVU͕ݺ͹ΕΔ w ϑϥάཱ͕ͬͯɺMBZPVU4VCWJFXT͕ݺ͹ΕΔ
 ʢϨΠΞ΢τΤϯδϯͷߋ৽λΠϛϯάʣ

  32. 2εΫϩʔϧ͕ΧΫͭ͘ w TDSPMM7JFX%JE4DSPMM ͳͲͰϨΠΞ΢τߋ৽Λ ଈ࣮࣌ߦͯ͠ͳ͍͔νΣοΫ w ϏϡʔͷϨΠΞ΢τௐ੔͕ϝΠϯεϨουΛϒ ϩοΫͯ͠͠·͍ɺεΫϩʔϧͷͨΊͷϨΠΞ ΢τௐ੔͕ࢭ·͍ͬͯΔՄೳੑ͋Γ w

    MBZPVU4VCWJFXT ΛPWFSSJEF͢Δͱྑ͍͔΋
  33. 2"VUP-BZPVUͰͷ
 Ξχϝʔγϣϯ͕ಈ͔ͳ͍ w GSBNFͰͷΞχϝʔγϣϯͱҧ͍ɺ
 ϒϩοΫ֎ʹߋ৽ॲཧΛॻ͘ ɾଈ࣌ߋ৽Λߦ͏ͨΊɺϒϩοΫ಺ͰlayoutIfNeeded()Λ ϨΠΞ΢τΛଈ࣮࣌ߦ ʢGSBNF͕ܾఆʣ


  34. 2ίʔυͰ੍໿Λ௥Ճͨ͠Βɺ
 ίϯϑϦΫτͨ͠ "VUP3FTJ[JOH.BTL༝དྷͷ
 ੍໿͕ࠞࡏ


  35. w USBOTMBUFT"VUPSFTJ[JOH.BTL*OUP$POTUSBJOUT ΛແޮԽ w σϑΥϧτͰઃఆ͞ΕΔ"VUPSFTJ[JOHΛ
 "VUP-BZPVUͷ੍໿ʹม׵͠ͳ͍ઃఆ

  36. ͝੩ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠