ããã«ã¡ã¯ãHabrïŒ ã¢ãã€ã«ã¢ããªã±ãŒã·ã§ã³ã®ã¢ãŒããã¯ãã£èšèšã«é¢ããäžé£ã®èšäºãç¶ããŸãã catã®äžã§ãUIã¬ã€ã€ãŒã®èšèšã«ã€ããŠèª¬æããŸãã ãããã
é²åããããŸããŸãªçš®é¡ã®çç©ã¯ãèªãã®çåã確ä¿ããããã«è§£æ±ºããå¿ èŠãããåºæ¬çãªèª²é¡ã«çŽé¢ããŸããã
ç°å¢ãããšãã«ã®ãŒãåžåããå¿ èŠããããŸããïŒ -解決çïŒå åæã
éºäŒåã®å€æ§æ§ã確ä¿ããå¿ èŠããããŸããïŒ -決å®ïŒæ§å¥åºåã
身äœãè€éã«ãªãã°ãªãã»ã©ãããé«åºŠãªèª²é¡ã解決ããªããã°ãªããŸããã§ããã
æéãçµã¡ãŸããã çååé¡ã®åªå 床ãèããäœäžããåäœã®è³æºãéšåçã«æªäœ¿çšã§ããçš®ãåºçŸããŸããã
é²åã¯æ°ãããã¯ãã«ãåãå ¥ããŸããã é£ç©ã§ããããæé£è ããã®ä¿è·ãã倩åããã®ä¿è·ããªã©ãèªç¶ã®åé¡ã®å€§éšåã¯äœããã®åœ¢ã§è§£æ±ºãããããã«çºå±ããå Žæã¯ã©ãã«ããªãããã«èŠããŸãããããã¡ã³ã¿ãžãŒãããã§åœ¹å²ãæãããŸããã
ãããªãé²åã¯ãã¯ãçåã確ä¿ãããšããç®æšãè¿œæ±ããŸããã§ããããæ°ããã¿ã¹ã¯ã®ãœãŒã¹ã¯æèã§ããããæåãããç§åŠããªã©ã®éçºãã¯ãã«ãçã¿åºããŸããã å®éãæè²ãšè²æã¯ãå人ã®çåãä¿èšŒããçŽæ¥çãªèŠå ã§ã¯ãªãã森æã«äœãã§ããéã«ããããªãã§è¡ãããšã¯éåžžã«å¯èœã§ãã
æè²ãšè²æã¯èªç¶ãèšå®ããèªç¶ãªç®æšã§ã¯ãªãã人éèªèº«ã«ãã£ãŠçãŸãããã®ã§ãã
çš®ã®ãããªãçºå±ã¯ããã®çš®ãèªãã®ããã«çºæããç®æšã«ãã£ãŠä¿èšŒãããŠããŸãã
ãããŠããããã®ç®æšã¯ããããå¶éäºé ã§ãã
å³æžé€šã§ã¯å€§å£°ã§è©±ããŸããã ããŒãã«ãäžžatã¿ããããšã¯ã§ããŸããã ããããã®èšç·Žãå¿ èŠã§ãïŒã®ã¿ãŒãæžããŠãæããŠãå°å·ããŠãæŒå¥ããŸã-ãªãã®å°é£ããªããããã¯èªåã«å¯ŸããæŽåã§ãã
éçºããããã«ã人ã¯èªåãçºæããæ çµã¿ã«èº«ã眮ãã
ãœãããŠã§ã¢ã·ã¹ãã ãé²åã®ããŒã¯ã«ãããã§ããïŒ
補åãåçã«æé·ããããã§ããïŒ
-ãªãžãããã¬ãŒã ãšæ¡åŒµãã¯ãã«ã䜿çšããŠãããžã§ã¯ããå®çŸ©ããŸãã
ããã°ã©ãã³ã°æåã§ã¯ããšã³ãžãã¢ã¯èªåãæãæ¹æ³ã§æžãã®ã§ã¯ãªããã«ãŒã«ã«æºæ ããæ¹æ³ã§æžãã®ã§ãã
Ps
ãã¡ããã3å±€ã®å»ºç¯èšèšã§ããããšãåç©ãä¿æããæåã§ããããšãã«ãŒã«ã¯äººã
ã«ãã£ãŠçºæããããã®ã§ãããæçµæ段ãšããŠå®¢èŠ³çã§ã¯ãããŸããã
äœãçå®ã§ã¯ãããŸããã
ãã¹ãŠèš±å¯ãããŠããŸãã
äœãçå®ã§ã¯ãããŸããã
ãã¹ãŠèš±å¯ãããŠããŸãã
äœèšã£ãŠãã®ïŒ
çš®ã®åé¢
äž»ã«ã¢ãã€ã«ã¢ããªã±ãŒã·ã§ã³ïŒä»¥äžãMPãšåŒã³ãŸãïŒã®ãµãŒãã¹ã¬ã€ã€ãŒãšãã©ã³ã¹ããŒãã¬ã€ã€ãŒã®ã¢ãŒããã¯ãã£èšèšã«çŠç¹ãåœãŠãååã®èšäºã§ã¯ãUIã¬ãã«ã®èšèšã®éçšã§ã©ã®ãããªåææ¡ä»¶ã«åŸãã¹ããã«ã€ããŠã®ãã³ããäžããããŸããã
以äžã¯çè«çãªèæ ®äºé ãšå®éçãªçµè«ã§ãããããããããªãã®äœæ¥ãç°¡çŽ åããéçºããããããžã§ã¯ãã«äžå®éã®æ§é ãè¿œå ããŸãã
NBé«å質ã®è£œåã§ãŠãŒã¶ãŒã€ã³ã¿ãŒãã§ã€ã¹ãæ§ç¯ããã€ããªãã®ãŒã¯ã¢ããªã±ãŒã·ã§ã³ãã©ãããã©ãŒã ã«å³å¯ã«çµã³ä»ããããŠããããœãªã¥ãŒã·ã§ã³ãéžæããéã«ããçš®ã®ãã¯ãã¹ãã©ãããã©ãŒã ããéæããããšã¯ççŽã«èšã£ãŠæããªããšã§ãã
Navigation DrawerãUITabBarãšåãæ©èœãå®è¡ã§ããå Žåã§ããããããã®ãŸãŸäœ¿çšããŠãå ã ç°ãªãããã«èšèšãããã·ã¹ãã ãåçã«ããããšã¯ã§ããŸããã
çŸåšã®èšäºã§ã¯ãäž»ã«iOSãã©ãããã©ãŒã ã«é©çšå¯èœãªãœãªã¥ãŒã·ã§ã³ã«çŠç¹ãåœãŠãŠããŸãã
ãã«ãUI
çŽ æŽãããã¹ããŒãªãŒãèªãç¶ãã
ååããããããŠãŒã¶ãŒã¹ããŒãªãŒã«ãªããŸãããããã«ããããããžã§ã¯ããè«ççãªéšåã«åå²ããŠããœãŒã¹ã³ãŒããç°¡åã«ç¶æã§ããããã«ãªããšèããããŸãã
ããªãã®ã¢ããªã±ãŒã·ã§ã³ã®ãã¶ã€ã³ãçã£ããªã¿ã¯ã«ãã£ãŠæãããã®ã§ã¯ãªãããUXãã®æŠå¿µã«ç²Ÿéããã¢ãã€ã«ããã€ã¹ã®ç»é¢ã®ãã§ãŒã³ã«ãã¹ãŠã®ã³ã³ãããŒã«ã䟿å©ãã€ææ©çã«ãã£ãããããããšãã§ããå€ããå°ãªããé©åãªã¢ãŒãã£ã¹ãã«ãã£ãŠæããããšä»®å®ããŸãã
éè¡æ¥åã¢ããªã±ãŒã·ã§ã³ã®äŸã䜿çšããŠãã€ã³ã¿ãŒãã§ãŒã¹ã¯æ¬¡ã®ãããªå žåçãªã¹ããŒãªãŒã«åå²ãããŸããã¢ããªã±ãŒã·ã§ã³ãè¡šãè€æ°ã®ã¹ã©ã€ãã§æ§æããããæšæ¶ãã ãŠãŒã¶ãŒåããã¹ã¯ãŒããé»åã¡ãŒã«ãªã©ã®ãã£ãŒã«ããæã€ãèªå¯ãã æåŸã«ãã¡ã€ã³ç»é¢ã¯ãããã€ãã®è«ççãªéšåã§æ§æãããŠããŸãïŒãããŒââã ãïŒãéã«ã€ããŠïŒããæ¯æããšééãããATMãšæ¯åºã®ããã«ãŒãããªã©ã
åã¹ããŒãªãŒã«ã¯ããŠãŒã¶ãŒãç¹å®ã®ã¢ã¯ã·ã§ã³ãå®è¡ã§ããããã€ãã®ç»é¢ïŒãŸãã¯ãããŒãžãïŒãå«ãŸããŠããŸãã
ãæ¯æããšééãïŒæ¯æãã®ãªã¹ãã«ç§»åããŸãã ãã¢ãã€ã«ã³ãã¥ãã±ãŒã·ã§ã³ãã»ã¯ã·ã§ã³ã«ç§»åããŸãã æŒç®åãéžæããŸãã é»è©±çªå·ãšè£å éé¡ãå ¥åãããéã®ãœãŒã¹ãéžæããŠãã ãã-ããªãã®ã¯ã¬ãžããã«ãŒã; æ¯æããŸãã
ãµãŒãã¹ã¬ãã«ã«ã¯ãUIã«å¿ èŠãªããŒã¿ãæäŸããããã¯ãšã³ãã§æŽ»çšã§ãããã¹ãŠã®å¿ èŠãªããŒã«ããããŸãã
ãšã³ãã£ãã£ãžã®åé¢ã«ã¯ãåŸæ¥ã®MVCã§ã¯ãªããMVPã®å€æŽã䜿çšããããšããå§ãããŸããããã«ãããããæœè±¡çãªã³ã³ãããŒã©ãŒãäœæããããŒã¿ã¢ãã«ã«é¢é£ä»ããããã³ãŒãããã®ããŒã¿ã®çŽæ¥ãæ¶è²»è ãã§ããã¯ã©ã¹ã«åæ£ã§ããŸãã
ãŠãŒã¶ãŒã¹ããŒãªãŒããšã«ã3ã€ã®äž»èŠãªçš®é¡ã®ãšã³ãã£ãã£ãåºå¥ã§ããŸãã ãããã¯ã View ã ViewController ãããã³Helperã§ãã
ViewController-ã€ã³ã¿ãŒãã§ãŒã¹ã®åã ã®è«çãŠãããã®ã³ã³ãããŒã©ãŒãšããŠæ©èœããã¯ã©ã¹ã ååãšããŠãã¢ããªã±ãŒã·ã§ã³ããŒãžã¯è«çãŠããããšããŠæ©èœããŸãããããè€éãªã¬ã€ã¢ãŠãã§ã¯ãããŒãžäžã®åã³ã³ãããŒã©ãŒãéžæããŠãã¶ãŒã¯ã©ã¹ããªãããŒããããšäŸ¿å©ã§ãã
ãã¥ãŒã¯ãã¹ããŒãªãŒããŒãã§çŽæ¥è¡šãããã¯ã©ã¹ã§ãïŒUIViewãUITableViewCellãUILabelãUIButtonãªã©ã®ç¶æ¿ã
ãã«ã㌠-åå¥ã®è·åãŸãã¯å§ä»»ãããè·åãå®è¡ãããŠãŒãã£ãªãã£ã¯ã©ã¹ã ãããã«ã¯ãæååãUITableViewDataSourceããã³UITableViewDelegateãããã³ã«ã«æºæ ããã¯ã©ã¹ãªã©ããã©ãŒãããããããã®ãŠãŒãã£ãªãã£ãå«ãŸããŸãã
詳现ã«ã€ããŠè©±ããŸãããã
ViewController
競åä»ç€ŸããåŠã¶
äžè¬çã«ãiOSéçºè ã¯AndroidãœãããŠã§ã¢ãäœæããååããå€ããåŠã¶å¿ èŠããããŸãã
åŸè ã¯ãå€å žçãªJavaãšã³ãžãã¢ã«åºæã®ãã¹ãŠã®åæ§ãšã¢ãŒããã¯ãã£ãããçšåºŠç¶æ¿ããŠãããããå®éã«ã¯ãŒã«ãªAndroidã¢ããªã±ãŒã·ã§ã³ã®ã¢ãŒããã¯ãã£èšèšã¯ãã¯ãŒã«ãªiOSã¢ããªã±ãŒã·ã§ã³ã®ã¢ãŒããã¯ãã£èšèšãããã¯ããã«èª¿åããŠããããã«èŠããŸãã
Androidã®ååãæåã«å°å ¥ããå¶éã¯ãã³ã³ãããŒã©ãŒïŒã¢ã¯ãã£ããã£ïŒéã§è€éãªãªããžã§ã¯ãã転éã§ããªãããšã§ããããã®ããããããã®ãªããžã§ã¯ãã®ã·ãªã¢ã«åãä¿èšŒããããšãããã«å¿ èŠã§ãã
ã¯ããä»ã§ã¯èª°ãããã§ã«ãã©ã°ã¡ã³ãã䜿çšããŠããããã®ã¹ããŒãªãŒå šäœãå¿åŽã«æ²ãã§ããŸãããå ã®ã¡ãã»ãŒãžã¯æ£ããã£ãã§ããåã³ã³ãããŒã©ãŒã¯å¯èœãªéãåé¢ããå¿ èŠããããŸãã
ã³ã³ãããŒã©éã§ãšã³ãã£ãã£å šäœãæž¡ããªãã§ãã ãã-ãããã®èå¥åãæž¡ããŸãã åã³ã³ãããŒã©ãŒããµãŒãã¹ã¬ãã«èªäœãããã¯ãããããããã®ãšã³ãã£ãã£ãŒã®è©³çŽ°æ å ±ãïŒãã®èå¥åãä»ããŠïŒåä¿¡ããŸããããã«ãããåœä»€åããã°ã©ãã³ã°ã«åºæã®æå°éã®å¯äœçšãã¢ããªã±ãŒã·ã§ã³ã«æäŸã§ããŸãã
ãããŠãã¡ãããAndroidéçºè ãåŠã¶ã¹ã2çªç®ã®å¶é-SDKã§ãAdapterããããŒãã«ããªã²ãŒããšããŠäœ¿çšããŸã-ããã¯ãããã³ã«ã§ã¯ãªããå¥åã®ã¯ã©ã¹ãªã®ã§ãView ControllerãUITableViewDelegate / UITableViewDataSourceãªã©ãããŒãžããŸã-åã«äžå¯èœã
NBã¯ãªã¢ããã¹ãã UITableViewControllerã¯SOLIDã®ååã«çŽæ¥éåããŠããããããã®ã¯ã©ã¹ãçºæããAppleã®ãšã³ãžãã¢ã¯é倧ãªãã¹ãç¯ããŸããã
衚瀺ãã
æœè±¡åããã¹ã¿ã€ã«ã«åå²ãã
äžèšã§MVPã®äœ¿çšã«ã€ããŠæ¢ã«èª¬æããŸãããã次ã«ãã®çç±ã説æããŸãã
ãã®ãããã»ã«ã«ããŒã¿ãå ¥åããããã®2ã€ã®ãã©ã°ã¡ã³ãããããŸãã
MVCïŒ
RMREntity * entity = [self entityForIndexPathïŒindexPath];
cell.title = entity.name;
cell.subtitle = entity.shortDescription;
MVPïŒ
RMREntity * entity = [self entityForIndexPathïŒindexPath];
[cell fillWithEntityïŒentity];
2çªç®ã®ã¢ãããŒãã§ã¯ãUIã®æ§é ããæœè±¡åããŠãã³ã³ãããŒã©ãŒã®ãã¹ãŠã®ããžãã¯ãšãã«ããŒããŒã¿ãåŠçæžã¿ã®ããŒã¿åRMREntityã«éäžãããŸãã
ãããã£ãŠãâfillWithEntityïŒã€ã³ã¿ãŒãã§ã€ã¹ã®èåŸã§ãããŒã¹ã®RMRTableViewCellåå«ã¯ã©ã¹ãé衚瀺ã«ã§ããŸããååã¯ã©ã¹ã¯ãç¬èªã®æ¹æ³ã§ãšã³ãã£ãã£ãã¬ã³ããªã³ã°ã§ããŸãã åæã«ãåUITableViewã«å¯ŸããŠåã UITableViewDataSourceã䜿çšãããããå®åã³ãŒãã®èšè¿°ãå€§å¹ ã«ç¯çŽã§ããŸãã
åèš
ãŸããå¿ããªãã§ãã ããïŒãã¥ãŒã¯SDKã¯ã©ã¹ããã ãã§ãªããçžäºãããç¶æ¿ã§ããŸãã
ãã¢ããªã±ãŒã·ã§ã³ã®ã¢ãŒããã¯ãã£èšèšã§ã¯ãã¢ããªã±ãŒã·ã§ã³ã®çš®é¡ã«ã€ããŠèª¬æããå¿ èŠããããŸãã å³æžé€šã®èšèšå³ãèŠããšããããå³æžé€šã§ããããšãæ£ç¢ºã«ç解ã§ããŸããèªæžå®€ãšæ¬æ£ããããŸãïŒâ
ã¢ããªã±ãŒã·ã§ã³ã«MessageããŒã¿åããããŸããïŒ ãã®äžã«æœè±¡MessageCellã»ã«ãäœæããããããä»ã®ã»ã«ãç¶æ¿ããŸãïŒ ã³ãŒãã®åã¯ã©ã¹ã¯ããã®æ©èœã決å®è«çã«æºããå¿ èŠããããããžãã¯ãå«ããããšã¯ã§ããŸããã
äºçªç® ã UXã«ç²ŸéããŠãããã¶ã€ããŒã«ã€ããŠèšåããããšãèŠããŠããŸããïŒ
åªãããã¶ã€ããŒã¯ãåªããããã°ã©ããŒã«å°ã䌌ãŠããŸãã
圌ã¯ãããããã®ããŒãºã«é©å¿ã§ããå žåçãªãã³ãã¬ãŒãã®ã»ãããæã£ãŠããŸãã
åªãããã¶ã€ããŒã¯ããŸãã«ã©ãŒãã¬ãããäœæãã次ã«ãããäžè²«ããŠãããžã§ã¯ãã®ã¬ã³ããªã³ã°ã«é©çšããŸãã
è²ã«å ããŠãåªãããã¶ã€ããŒã¯åãããžã§ã¯ãã®ãã¹ã¿ã€ã«ã·ãŒãããåžžã«æã£ãŠããŸãã
ã¿ã€ãã«ïŒHelvetica Boldã36ptã
åå¹ïŒHelvetica Mediumã24ãã€ã³ãã
éé¡ïŒHelvetica Lightã18ãã€ã³ããã©ã€ããã«ãŒã
ãªã©ãªã©ã
é©åãªéçºè ãšããŠããã®ã¹ã¿ã€ã«ã·ãŒããã³ãŒãã«çŽæ¥è»¢éããããšã劚ãããã®ã¯ãããŸããã
ããšãã°ãåæåæã«ããã©ã³ãã¹ã¿ã€ã«ãè¿ããã¡ã¯ããªã¡ãœãã-fontStyleãç §äŒãããã®ã¹ã¿ã€ã«ãé©çšããæœè±¡Labelã¯ã©ã¹ãäœæã§ããŸãã
çžç¶äººã¯ãé çªã«ãåã«å¿ èŠãªå·çã¹ã¿ã€ã«ãè¿ããŸãã ãããã£ãŠãHeaderLabelãSubheaderLabelãMoneyAmountLabel ...ã®ã¯ã©ã¹ãæå ã«ãããŸãã ãããã¯ãäœæãããã¬ã€ã¢ãŠãã«é©çšå¯èœãªInterface Builderå ã®ãã¯ã©ã¹ããã£ãŒã«ãã«åçŽã«çœ®ãæããããšãã§ããŸãã
ãã«ããŒ
ãã¹ãèšèš
ã³ã³ãããŒã©ãŒãããŠã¯ãªããªãããšã«ã€ããŠã¯ãã§ã«è¿°ã¹ãŠããŸãã
ã ãã誰ããã¹ãã§ããïŒ -åçïŒãŠãŒãã£ãªãã£ã
èŠããŠå®ãã¹ãæãéèŠãªããšã¯ãåçŽãªã«ãŒã«ã§ããåå©äž»çŸ©ã®ã¯ã©ã¹ã¯æ å ±ãéãã§ã¯ãªããŸããã ãããã¯ãããªãã¯ããããã£ãæã£ãŠã¯ãªãããé¢æ°ã¹ã¿ã€ã«ã§èšè¿°ããŠããããã«ããã¹ãŠã®ããžãã¯ã¯æå°éã®voidã¡ãœããã§ããã¹ã¹ã«ãŒãããå¿ èŠããããŸããã¡ãœããã¯åžžã«äœããè¿ãå¿ èŠããããŸãã
ãŠãŒãã£ãªãã£ã®ãã®ãç¶æ ã®æ¬ åŠãã«ãããã¢ããªã±ãŒã·ã§ã³ããžãã¯ã®ç°ãªãã¬ã€ã€ãŒã§ã¢ããªã±ãŒã·ã§ã³ã¬ã€ã€ãŒã䜿çšããããšã¯éåžžã«å®å šã§ãããã³ã³ãããŒã©ãŒãè¡šçŸãããžãã¹ããžãã¯ãªã©ã®ããã«åå¥ã®ã¢ã·ã¹ã¿ã³ããäœæããã®ãæ ããªãã§ãã ããã
ãŠãŒãã£ãªãã£ã¯ã©ã¹ïŒãŸãã¯ããã©ãŒïŒã¯ããã¹ããšã³ãã£ãã£ã®åœ¹å²ã®æåã®åè£ã§ãã
æ¥ä»ã®ãã©ãŒããããé åã®äžŠã¹æ¿ããä»ã®ç»åããã®ç»åã®äœæ-ãããã¯ãã¹ãŠããé åãåäœãã¢ãµãŒããã®ã·ãŒã±ã³ã¹ã«ç°¡åã«åãŸãã¢ã«ãŽãªãºã ã§ãããèªåãã¹ãã«ç ç²ã«ãªãå¯èœæ§ããããŸãã
ãããã«
ãŸãšã
ãã®èšäºã§ã¯ã誰ã«ãæ瀺ãããããããŸããã§ããã
ãããããè©ã«ç¬èªã®é ãæã¡ããããããç¬èªã®çµè«ãåŒãåºãããšãã§ããŸãã ãŸãã¯ããŸã£ããçµè«ãåºããªãã§ãã ããã
ãã¡ããããããžã§ã¯ãã®æ§é ãã©ã®ããã«èŠããã¹ããããã¡ã€ã«ããã£ã¬ã¯ããªãã©ãã«çœ®ãã¹ããããªãœãŒã¹ãã©ãã«ããã¹ãããšãã£ãããã詳现ãªããšãæžãããšãã§ããŸãã
ã¯ã©ã¹ã«ã¡ãœãããå®è£ ããé åºãããããã£ã«ååãä»ããæ¹æ³ã
ããããç§ã¯æèçã«ãããããŸããã§ããïŒãœãŒã¹ã³ãŒããè€éã§ããå¿ èŠããªãã®ã§ ãææã¯æå³çã«åçŽã§ãã
äžç·ã«ããŠãã ããã