Storyboard Reference ãããæã
åå¼·ä¼ã§æã¡å¸°ã£ããããã¯ãæ°ã«ãªã£ã
å æ¥åå ãã iOS 9 ã®åå¼·ä¼ã«ã¦ã岸å·å å·±ãã@Realm ã話ããã Storyboard Reference ã®è©±ãé常ã«èå³æ·±ãã£ãã®ã§ãèªåãªãã«è¿½å 調æ»ãã¦ã¿ã¾ããã
ã¾ãã¯storyboardã®æ¬ ç¹ã¨ã
storyboardã¯ãxibã§ã®éçºã¨æ¯ã¹ã¦ãç»é¢ã®é·ç§»ãè¦è¦çã«åãããããã®ã¨ãsegueãå©ç¨ã§ããã¨ããå©ç¹ãããã¾ããã§ããããã¡ã¤ã«ãï¼ã¤ãªã®ã§ããã¼ã éçºãè¡ãã¨ç«¶åãããããåæ¥ãã¥ããã¨ããæ¬ ç¹ãããã¾ãã
ãã®ãããsegueãå©ç¨ã§ããã¨ããå©ç¹ãç ´æ£ãã¦ã§ãç»é¢ãã¨ãæ©è½ãã¨ã«storyboardãåå²ãããã¨ããææ³ãé¸æãããã¡ã ã¨æãã¾ãã
åå²ããå¥ã®storyboardãå©ç¨ããããã«ã¯ãããã°ã©ã å´ã§ããããããæéãçºçãã¦ãã¾ãã¾ããé·ç§»ã«segueã¯å©ç¨ã§ãããè¦è¦çã«ãä¼ããã¥ãããªã£ã¦ãã¾ãã®ã§ãåºæ¥ãã°é¿ãããã§ããã
ã¡ãªã¿ã«ãstoryboardã«ã¤ãã¦ãã¾ããåç¥ãªãæ¹ã¯ããã®è¾ºããåèã«ãã¦ã¿ãã¨ããããããã¾ããã
ã¼ã£ã¡éçºã§ãå°ãæã¯å°ã
èªåã®ããã«ï¼äººã§ä½æ¥ããåã«ã¯ãåæ¥ãèããå¿ è¦ã¯ãã¾ãããã¾ãããã§ãããï¼ã¤ã®storyboardãã¡ã¤ã«ãè¨ãä¸ãã£ã¦ãã¾ãã®ã¯ããã¯ããã¾ãå¬ããç¶æ³ã§ã¯ãªãã§ããã
ã¡ãªã¿ã«ãèªåããªãªã¼ã¹ãã¦ããæã¢ããªã®storyboardã¯ãããªæãã§ãæãã®ãæ¥ããããããã管çãè¡ãå±ãã¦ããã¾ãã...
ã§ãããXcode 7 ããã¯ããã®æ¬ ç¹ãè£ãã¹ããStoryboard Reference ã¨ããæ©è½ã追å ããã¾ããã
Storyboard Reference ã¨ã¯ï¼
Storyboard Reference ã¯ãåå²ããstoryboardãã¡ã¤ã«å士ãåç §ããsegueã§ã¤ãªããã¨ãã§ããæ©è½ã§ãã
ã¤ã¾ãå ã»ã©æããããã¡ã¤ã«åå²æã®æ¬ ç¹ãè£ãããã¨ãããã¨ã§ããï¼
- å¥ã®storyboardã¸ã®åç §ãsegueã§è¨è¿°ã§ãã
- é·ç§»ã®ããã®ããã°ã©ã è¨è¿°ã¯ä¸è¦
ã¨ãããã使ã£ã¦ã¿ã
ã¾ãã¯ä»ã¾ã§éãã«
ã¾ãã¯ãããªæãã§ãç»é¢Aã®ãã¿ã³ãã¿ããããã¨ç»é¢Bã«PUSHé·ç§»ãè¡ããã¨ããstoryboardãä½ã£ã¦ã¿ã¾ããããã¾ã§éãã§ãç¹çãã¹ãç¹ã¯ç¡ãã§ããã
å¥ã®storyboardãã¡ã¤ã«ãä½ã
次ã«ãå¥ã®storyboardãã¡ã¤ã«ãçæãã¾ãï¼Green.storyboardï¼ãããã«ãViewControllerãï¼ã¤é ç½®ãã¦ãã³ã¬ã Initial ViewController ã¨ãã¾ãããã®ç»é¢ã¯ç»é¢Cã¨ãã¾ãã
Storyboard Reference ã使ãï¼
ç»é¢Bä¸ã«ãã¿ã³ãé ç½®ãããã®ãã¿ã³ãã¿ãããããç»é¢Cã«é·ç§»ããããã«ãã¾ãããã
Main.storyboardã«ãå³ä¸ã®ãªãã¸ã§ã¯ãä¸è¦§ãããstoryboard reference ããã©ãã°ãã¦é ç½®ãã¾ãï¼â ï¼ã
ãã® Storyboard Reference ã Green.storyboard ãåç §ããããã«è¨å®ãã¾ãï¼â¡ï¼ã
ç»é¢Bä¸ã®ãã¿ã³ããããã® Storyboard Reference ã«å¯¾ãã¦PUSHé·ç§»ã®segueãè¨å®ãã¾ãï¼â¢ï¼ã
ããã§åããã¦ã¿ãã°ãç»é¢A â ç»é¢B â ç»é¢C ã®é çªã§é·ç§»ãã¦ããã¨æãã¾ãã
æ¢åã®ãã¡ã¤ã«ãåå²ããå ´åã¯ï¼
èªåã®ã¢ããªã®ããã«ããã§ã«è¨ããã§ããstoryboardãåå²ããã®ããç·¨éã¡ãã¥ã¼ããç°¡åã«è¡ããã¨ãã§ãã¾ãã
ä»åã¯ãMain.storyboard ã® ç»é¢B ããå¥ã®storyboardãã¡ã¤ã«ã¨ãã¦åé¢ãã¦ã¿ã¾ãã
storyboardãåå²ããã
åé¢ããããªãã¸ã§ã¯ããé¸æããç¶æ ã§ï¼â ï¼ãEditor â Refactor to Storyborad ... ãé¸æãã¾ãï¼â¡ï¼ã
æ°ããstoryboardãçæããã
ããããã¨ãæ°ãã«storyboardãçæããã¾ãï¼ï¼ãã¡ã¤ã«å㯠Blue.storyboard ã¨ãã¾ãããï¼
ä¸ã«ã¯ ç»é¢B ã® ViewController ããã£ã¦ããããã Green.storybard ã«é·ç§»ã§ããããã«ãªã£ã¦ããã¿ããã§ããæ³å®éãã§ããã
å ã«ãªã£ããã¡ã¤ã«ãå¤æ´ããã¦ã¾ãã
åå²å ã¨ãªã£ã Main.storyboard ããæ£ããå¤æ´ããã¦ããããã§ãã
è¦ã¦ã¿ã¦ãã¨ãç»é¢A ã® ViewController ã®ã¿ã«ãªã£ã¦ãããç»é¢B ã®ä»£ããã«Storyboard Reference ãé ç½®ããã¦ãã¾ããããã¯ãå ã»ã©çæããã Blue.storyboard ãåç §ãã¦ããããã§ãã
ãã®æ¹æ³ã使ãã°ããã§ã«è¨ããã§ãã¾ã£ãstoryboardãã¡ã¤ã«ãæ±ãã¦æ©ãã§ããæ¹ããç°¡åã«ãã¡ã¤ã«ãåå²ã§ãããã§ãããã
iOS 9 ã®ã¿ã§ä½¿ããæ©è½ãªã®ï¼
ã¡ãªã¿ã«ããã® Storyboard Reference ã¯ãã©ã®ãã¼ã¸ã§ã³ã®iOSããµãã¼ããã¦ããã®ã§ãããã...ï¼
ä»åä½æããã¢ããªã¯ãDeployment Target ã 9.0 ã«ãã¦ãã¾ããããããã 8.0, 7.0 ã«å¤æ´ãã¦ãã«ããã¦ã¿ã¾ãã
ã©ããããStoryboard Reference ã¯ãiOS 8.0 以éã®æ©è½ã£ã½ãã§ããã
Relationship Segue ãè¡ãã¡ãã
Navigation Controller ã Tab Bar Controller ã®ãããªã³ã³ãã系㮠ViewController ã«ã¯ãé¢ä¿æ§ãå®ç¾©ãã Relationship Segue ã¨ããsegueãè¨å®ãã¾ãããããã«ããStoryboard Reference ãå©ç¨ã§ãã¾ãã
ãã¼ã¹ã«ããNavigation Controller
ãã¼ã¹ã«ã¯ Navigation Controller ãé ç½®ãã¦ãã¾ããNavigation Controller ã®å ´åã¯ãRelationship Segue ãå©ç¨ã㦠Root ViewController ãè¨å®ããå¿ è¦ãããã¾ãã
ä»å㯠Storyboard Reference ãå©ç¨ãã¦ããã®ã§ãRoot ViewController ã«ã¯ãå¥ã®storyboardãã¡ã¤ã«ã«å®ç¾©ããã ViewController ãè¨å®ãã¦ãã¾ãã
Tab Bar Controller ãä¸ã«ãã
Navigation Controller ã® Root ViewController ã«ã¯ãTab Bar Controller ãè¨å®ãã¦ãã¾ããå½ç¶ããã® Tab Bar Controller ã¯ãInitial ViewController ã¨ãã¦è¨å®ããã¦ãã¾ãã
Tab Bar Controller ã«ããRelationship Segue ãå©ç¨ãã¦ãåTabã® ViewControllers ãè¨å®ããå¿ è¦ãããã¾ããããã Storyboard Reference ãå©ç¨ããå¥ã®storyboardãã¡ã¤ã«ã«å®ç¾©ããã ViewController ãè¤æ°è¨å®ãã¦ãã¾ãã
åã¿ããã¨ã® ViewController
åã¿ãã«å©ç¨ãã¦ãã ViewController ã¯ãä¸ã¤ã®storyboardãã¡ã¤ã«ã«ã¾ã¨ãã¦å®ç¾©ãã¦ãã¾ãã
...ããï¼Initial ViewController ãå®ç¾©ããã¦ããªããï¼ã¡ããã¨å¼ã°ããã®ï¼ï¼ã¨ãæãæ¹ãããããããã¾ããã
Storyboard Reference ãå©ç¨ããå ´åã¯ãããã¾ã§èª¬æãçãã¦ãããå©ç¨ããstoryboardãã¡ã¤ã«ãæå®ãã¦ãInitial ViewController ã«è¨å®ãããViewControllerãå¼ã³åºãæ¹æ³ãã¨ãå©ç¨ããstoryboardãã¡ã¤ã«ã¨ãå©ç¨ããViewControllerã® Storyboard ID ãæå®ããæ¹æ³ãã®ï¼éãããã¾ãã
Storyboard ID ã使ãå ´å
ï¼ã¤ã®storyboardã«è¤æ°ã®ViewControllerãå®ç¾©ãã¦ããå ´åã¯ãå¾è ã®æ¹æ³ãæ¡ç¨ãããã¨ã§ãå©ç¨ããViewControllerã使ãåãããã¨ãã§ãã¾ãã
ãã®å ´åãåViewControllerã«ã¯ãããããä¸æã¨ãªã Storyboard ID ãå®ç¾©ããå¿ è¦ãããã¾ãã
ããã¦ããããã®ViewControllerãå©ç¨ããStoryboard Referenceã«ã¯ãstoryboardãã¡ã¤ã«åã¨Reference IDï¼Storyboard IDï¼ãè¨å®ãã¾ãã
ããã iOS 8 ã§å©ç¨ãããã¨ããã¨...
å ã»ã©èª¿æ»ããããã«ãStoryboard Reference 㯠iOS 8 以éã§ä½¿ãããã ããªãã¨æã£ã¦ããã¨...æããã¾ãã
ã©ããããRelationship Segue ã«å¯¾ã㦠Storyboard Reference ãå©ç¨ããå ´åã¯ãDeployment Target ã 9.0 以éã§ããå¿ è¦ãããã¿ããã§ããã
ã¨ãããã¨ã§ãiOS 8 ç³»ãã¿ã¼ã²ããã¨ããã¢ããªã®å ´åã¯ãrelationship segue ã«å¯¾ã㦠Storyboard Reference ãå©ç¨ããªãããã«ãã¾ãããï¼
åå²ãã¡ãã㨠unwind segue ã£ã¦ä½¿ããªãã®...ï¼
å人çã«ã¯ãã¢ã¼ãã«ãéããéã« unwind segue ã使ãã®ã§ããããã¡ã¤ã«ãåå²ãã¡ããã¨ä½¿ããªããªã£ã¡ããã§ãããã...ï¼ã¡ãã£ã¨è©¦ãããã ãã©ãããæ¹ãããããªãã£ãã§ãã
è¨å®ç»é¢ã¯ã¢ã¼ãã«è¡¨ç¤ºã§ãStoryboard Reference ã使ããï¼ ã¿ãããªãã¨ã£ã¦ãå²ã¨æ®éã«ãããããªã®ã§ãããããããå ´å㯠unwind segue ã¯è«¦ããã£ã¦ãã¨ãªã®ããª...ï¼
ãã®ä»¶ã«é¢ãã¦ã¯ãããå°ã調æ»ããªãã¨ãããªãã§ããï¼æ±ï¼
æ©ã使ãããæ©è½ã ããiOS 7 ã¨ãåãã¾ããããã
ã¨ãããã¨ã§ãStoryboard Referenceã¯ãã¨ã¦ãé åçã§éçºã«ãè¯ãå¹æãä¸ããããªæ°æ©è½ã§ããããã¼ã éçºãè¡ã£ã¦ããç¾å ´ã§ã¯ãç¹ã«éå®ãããããããªãã§ãããã
ãã ããã®æ©è½ãå°å ¥ããã«ã¯ãæä½ã§ã iOS 7 ã®ãµãã¼ããçµäºããå¿ è¦ãããã¾ãããµã¼ãã¹ã¸ã®å½±é¿ã¯å°ãããªãããããã¾ããã®ã§ããµã¼ãã¹ã®è¦æ¨¡ã«ãã£ã¦ã¯ãæ éã«ãªããããããªãããããã¾ããã...
ã¡ãªã¿ã«ãèªåã®æã¢ããªã®iOSãã¼ã¸ã§ã³åå¸ã¯ãããªæãã§ããã
ãã iOS 7 åã£ã¦ããããªãã£ããï¼