{"id":1641,"date":"2017-04-26T14:38:10","date_gmt":"2017-04-26T05:38:10","guid":{"rendered":"http:\/\/lovelinux.mydns.jp\/?p=1641"},"modified":"2017-04-26T14:38:10","modified_gmt":"2017-04-26T05:38:10","slug":"react-native-%e3%83%87%e3%83%90%e3%82%a4%e3%82%b9%e3%81%ae%e7%b8%a6%e5%90%91%e3%81%8dportrait%e3%80%81%e6%a8%aa%e5%90%91%e3%81%8dlandscape%e3%81%ae%e5%a4%89%e5%8c%96%e3%82%92%e6%8d%89%e3%81%88","status":"publish","type":"post","link":"https:\/\/lovelinux.mydns.jp\/?p=1641","title":{"rendered":"React Native \u30c7\u30d0\u30a4\u30b9\u306e\u7e26\u5411\u304d(PORTRAIT)\u3001\u6a2a\u5411\u304d(LANDSCAPE)\u306e\u5909\u5316\u3092\u6349\u3048\u308b\uff08\u30a4\u30d9\u30f3\u30c8\uff09"},"content":{"rendered":"<h3>\u306f\u3058\u3081\u306b<\/h3>\n<p>React Native\u3092\u521d\u3081\u3066\uff11\uff10\u65e5\u307b\u3069\u304c\u7acb\u3061\u307e\u3057\u305f\u3002\u753b\u9762\u30c7\u30b6\u30a4\u30f3\u304c\u96e3\u3057\u3044\u3067\u3059\u306d\u3002<br \/>\nflex layout\u3092\u4f7f\u3046\u3068\u3001\u305d\u308c\u306a\u308a\u306e\u753b\u9762\u306f\u51fa\u6765\u307e\u3059\u304c\u30fb\u30fb\u30fb<br \/>\n\u30d8\u30c3\u30c0\u30fc(Navigation)\u3068\u30d5\u30c3\u30bf\u30fc(Menu or Tab)\u306e\u30b5\u30a4\u30ba\u304c \u66d6\u6627\u306b\u306a\u308a\u3001<br \/>\n\u6642\u306b\u306f\u96a0\u308c\u3066\u3057\u307e\u3046\u30b1\u30fc\u30b9\u3082\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>\u3067\u3001\u3069\u3046\u3059\u308a\u3083\u3044\u3044\u3093\u3060\u3068\u8003\u3048\u3066\u3001\u4eca\u3001\u601d\u3044\u3064\u3044\u305f\u306e\u306f\u3001<br \/>\nflex layout\u3092\u8ae6\u3081\u3066\u3001\u56fa\u5b9a\u30d4\u30c3\u30c1\u3067\u753b\u9762\u30c7\u30b6\u30a4\u30f3\u3092\u3057\u3066\u3084\u308b\u3053\u3068\u3002<br \/>\n\u56fa\u5b9a\u30d4\u30c3\u30c1\u3068\u8a00\u3063\u3066\u3082\u3001\u30c7\u30d0\u30a4\u30b9\u306e\u753b\u9762\u30b5\u30a4\u30ba\u3092\u5224\u5b9a\u3057\u3066\u3001<br \/>\n\u30d8\u30c3\u30c0\u30fc\u306f\u3053\u306e\u9ad8\u3055\u3001\u30e1\u30a4\u30f3\u306e\u30b3\u30f3\u30c6\u30f3\u30c4\u306f\u3053\u306e\u9ad8\u3055\u3001\u30d5\u30c3\u30bf\u30fc\u306f\u3053\u306e\u9ad8\u3055<br \/>\n\u3068\u3044\u3046\u306e\u3092\u8a08\u7b97\u3067\u6c42\u3081\u3066\u3084\u308b\u306e\u304c\u3001\u4e00\u756a\u30b9\u30de\u30fc\u30c8\u304b\u306a\u3068\u3044\u3046\u6c17\u304c\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u305d\u3053\u3067\u3001\u30c7\u30d0\u30a4\u30b9\u306e\u5411\u304d\u304c\u7e26\u5411\u304d\u304b\u3089\u6a2a\u5411\u304d\u306b\u5909\u5316\u3001\u305d\u306e\u9006\u3001\u4e21\u65b9\u306b\u5bfe\u5fdc\u3057\u3066<br \/>\n\u3069\u3093\u306a\u30ed\u30b8\u30c3\u30af\u3092\u66f8\u3051\u3070\u3044\u3044\u304b\u8003\u3048\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n<h3>\u753b\u9762\u3092\u69cb\u6210\u3059\u308b\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8<\/h3>\n<p>\u3060\u3044\u305f\u3044\u3053\u3093\u306a\u30a4\u30e1\u30fc\u30b8\u3067\u30fb\u30fb\u30fb<br \/>\nindex.android.js \u3084 index.ios.js \u3067\u3000\u3053\u308c\u3089\u3092\u542b\u3093\u3060 View\u3092\uff11\u3064\u30ec\u30f3\u30c0\u30ea\u30f3\u30b0\u3057\u3066\u3084\u308b<br \/>\n\u3088\u3046\u306a\u30a4\u30e1\u30fc\u30b8\u3067\u3059\u3002<\/p>\n<p><a href=\"http:\/\/lovelinux.mydns.jp\/wp-content\/uploads\/2017\/04\/rn-1.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/lovelinux.mydns.jp\/wp-content\/uploads\/2017\/04\/rn-1.png\" alt=\"rn-1\" width=\"355\" height=\"571\" class=\"alignnone size-full wp-image-1642\" \/><\/a><\/p>\n<h3>\u30c7\u30d0\u30a4\u30b9\u306e\u5411\u304d\u306e\u5909\u5316\u3092\u6349\u3048\u308b<\/h3>\n<p>\u3053\u308c\u3001 View\u306b onLayout\u3068\u3044\u3046\u30a4\u30d9\u30f3\u30c8\u304c\u3042\u308a\u307e\u3059\u306e\u3067\u3001\u3053\u3044\u3064\u3092\u4f7f\u3044\u307e\u3059\u3002<br \/>\n\u3053\u3044\u3064\u3068\u3001Dimensions\u304b\u3089\u6c42\u3081\u3089\u308c\u308b\u30c7\u30d0\u30a4\u30b9\u306e\u753b\u9762\u30b5\u30a4\u30ba\u3092\u7d44\u307f\u5408\u308f\u305b\u3066\u3001<br \/>\n\u30d8\u30c3\u30c0\u30fc\u30fb\u30d5\u30c3\u30bf\u30fc\u30fb\u30e1\u30a4\u30f3\u30b3\u30f3\u30c6\u30f3\u30c4\u306e\u9ad8\u3055\u3092\u8a08\u7b97\u3057\u307e\u3059\u3002<br \/>\n\u305d\u308c\u3092 setState\u306a\u3093\u304b\u3092\u4f7f\u3063\u3066\u3001\u8a2d\u5b9a\u3057\u3066\u3042\u3052\u3066\u3001\u753b\u9762\u3092\u518d\u63cf\u753b\u3059\u308c\u3070OK\u3067\u3059\u3002<\/p>\n<p>\u65e5\u672c\u8a9e\u3067\u66f8\u304f\u3068\u3042\u3063\u3055\u308a\u3057\u3066\u307e\u3059\u304c\u3001\u5b9f\u969b\u5b9f\u88c5\u3059\u308b\u3068\u306a\u308b\u3068<br \/>\n\u305d\u308c\u306a\u308a\u306b\u30b3\u30fc\u30c9\u3092\u66f8\u304b\u306a\u304d\u3083\u306a\u308a\u307e\u305b\u3093\u3002<\/p>\n<p>index.android.js \u306e\u4f8b<\/p>\n<p>[bash]<br \/>\nimport React from &#8220;react&#8221;<br \/>\nimport {View, Dimensions, Alert} from &#8220;react-native&#8221;<\/p>\n<p>\u301c\u3000\u4e2d\u7565\u3000\u301c<\/p>\n<p>\thandleLayoutChange(event) {<br \/>\n\t\tlet {height, width} = Dimensions.get(&#8220;window&#8221;)<br \/>\n\t\tif (height > width) {<br \/>\n\t\t\tAlert.alert(&#8220;\u7e26\u5411\u304d PORTRAIT&#8221;)<br \/>\n\t\t}<br \/>\n\t\telse{<br \/>\n\t\t\tAlert.alert(&#8220;\u6a2a\u5411\u304d LANDSCAPE&#8221;)<br \/>\n\t\t}<br \/>\n\t}<\/p>\n<p>\trender() {<br \/>\n\t  <View\n\t\tstyle={styles.contents}\n\t\tonLayout={(event) => {<br \/>\n\t\t  this.handleLayoutChange(event)<br \/>\n\t\t}}><br \/>\n\t\t<Nav height={\u7e26\u5411\u304d or \u6a2a\u5411\u304d\u306e\u9ad8\u3055} \/><br \/>\n\t\t<Home height={\u8a08\u7b97\u3057\u3066\u5c0e\u304d\u51fa\u3057\u305f\u9ad8\u3055} \/><br \/>\n\t\t<Menu height={\u7e26\u5411\u304d or \u6a2a\u5411\u304d\u306e\u9ad8\u3055} \/><br \/>\n\t  <\/View><br \/>\n\t}<\/p>\n<p>\u301c\u3000\u4e2d\u7565\u3000\u301c<br \/>\n[\/bash]<\/p>\n<h3>\u52d5\u4f5c\u30a4\u30e1\u30fc\u30b8<\/h3>\n<p>\u5b9f\u969b\u306b\u3046\u307e\u304f\u8a08\u7b97\u3067\u304d\u308b\u3068\u3001\u3053\u3093\u306a\u611f\u3058\u306b\u306a\u308a\u307e\u3059\u3002<br \/>\n<a href=\"http:\/\/lovelinux.mydns.jp\/wp-content\/uploads\/2017\/04\/rn-2-1.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/lovelinux.mydns.jp\/wp-content\/uploads\/2017\/04\/rn-2-1.png\" alt=\"rn-2\" width=\"1376\" height=\"861\" class=\"alignnone size-full wp-image-1643\" \/><\/a><\/p>\n<h3>\u3042\u3068\u304c\u304d<\/h3>\n<p>React Native\u4ee5\u5916\u3067\u30b9\u30de\u30db\u5411\u3051\u306e\u30a2\u30d7\u30ea\u3092\u4f5c\u3063\u305f\u3053\u3068\u304c\u306a\u3044\u306e\u3067\u3001<br \/>\n\u5b9f\u969b\u306b\u3053\u3093\u306a\u30ed\u30b8\u30c3\u30af\u3092\u5b9f\u88c5\u3057\u306a\u3044\u3068\u3044\u3051\u306a\u3044\u306e\u304b\u3069\u3046\u304b\u3088\u304f\u5206\u304b\u3063\u3066\u304a\u308a\u307e\u305b\u3093\u3002\u3002<br \/>\n\u306a\u3093\u3067\u3001\u30d5\u30c3\u30bf\u30fc\u3092\u753b\u9762\u306e\u4e0b\u306b\u306f\u308a\u3064\u3051\u308b\u3053\u3068\u3050\u3089\u3044\u51fa\u6765\u306a\u3044\u3093\u3060\u3088\u30fb\u30fb\u30fb<br \/>\n\u3068\u601d\u3044\u307e\u3059\u304c\u3001\u4eca \u8efd\u304f\u8abf\u3079\u305f\u611f\u3058\u3067\u306f\u3001\u65b9\u6cd5\u306f\u306a\u3055\u305d\u3046\u306a\u306e\u3067\u3001<br \/>\n\u30b4\u30ea\u30b4\u30ea\u8a08\u7b97\u3057\u3066\u6c42\u3081\u3061\u3083\u3046\u65b9\u6cd5\u304c\u3001\u4e00\u756a\u624b\u3063\u53d6\u308a\u65e9\u3044\u6c17\u304c\u3057\u307e\u3059\u3002<\/p>\n<p>\u3082\u3063\u3068\u30b9\u30de\u30fc\u30c8\u306a\u65b9\u6cd5\u304c\u3042\u308c\u3070\u3001\u3058\u3083\u3093\u3058\u3083\u3093\u30b3\u30e1\u30f3\u30c8\u304f\u3060\u3055\u3044\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u306f\u3058\u3081\u306b React Native\u3092\u521d\u3081\u3066\uff11\uff10\u65e5\u307b\u3069\u304c\u7acb\u3061\u307e\u3057\u305f\u3002\u753b\u9762\u30c7\u30b6\u30a4\u30f3\u304c\u96e3\u3057\u3044\u3067\u3059\u306d\u3002 flex layout\u3092\u4f7f\u3046\u3068\u3001\u305d\u308c\u306a\u308a\u306e\u753b\u9762\u306f\u51fa\u6765\u307e\u3059\u304c\u30fb\u30fb\u30fb \u30d8\u30c3\u30c0\u30fc(Navigation)\u3068\u30d5\u30c3\u30bf\u30fc(Menu or Tab)\u306e\u30b5\u30a4\u30ba\u304c \u66d6\u6627\u306b\u306a\u308a\u3001 \u6642\u306b\u306f\u96a0\u308c\u3066\u3057\u307e\u3046\u30b1\u30fc\u30b9\u3082\u3042\u308a\u307e\u3059\u3002 \u3067\u3001\u3069\u3046\u3059\u308a\u3083\u3044\u3044\u3093\u3060\u3068\u8003\u3048\u3066\u3001\u4eca\u3001\u601d\u3044\u3064\u3044\u305f\u306e\u306f\u3001 flex layout\u3092\u8ae6\u3081\u3066\u3001\u56fa\u5b9a\u30d4\u30c3\u30c1\u3067\u753b\u9762\u30c7\u30b6\u30a4\u30f3\u3092\u3057\u3066\u3084\u308b\u3053\u3068\u3002 \u56fa\u5b9a\u30d4\u30c3\u30c1\u3068\u8a00\u3063\u3066\u3082\u3001\u30c7\u30d0\u30a4\u30b9\u306e\u753b\u9762\u30b5\u30a4\u30ba\u3092\u5224\u5b9a\u3057\u3066\u3001 \u30d8\u30c3\u30c0\u30fc\u306f\u3053\u306e\u9ad8\u3055\u3001\u30e1\u30a4\u30f3\u306e\u30b3\u30f3\u30c6\u30f3\u30c4\u306f\u3053\u306e\u9ad8\u3055\u3001\u30d5\u30c3\u30bf\u30fc\u306f\u3053\u306e\u9ad8\u3055 \u3068\u3044\u3046\u306e\u3092\u8a08\u7b97\u3067\u6c42\u3081\u3066\u3084\u308b\u306e\u304c\u3001\u4e00\u756a\u30b9\u30de\u30fc\u30c8\u304b\u306a\u3068\u3044\u3046\u6c17\u304c\u3057\u3066\u3044\u307e\u3059\u3002 \u305d\u3053\u3067\u3001\u30c7\u30d0\u30a4\u30b9\u306e\u5411\u304d\u304c\u7e26\u5411\u304d\u304b\u3089\u6a2a\u5411\u304d\u306b\u5909\u5316\u3001\u305d\u306e\u9006\u3001\u4e21\u65b9\u306b\u5bfe\u5fdc\u3057\u3066 \u3069\u3093\u306a\u30ed\u30b8\u30c3\u30af\u3092\u66f8\u3051\u3070\u3044\u3044\u304b\u8003\u3048\u3066\u307f\u307e\u3057\u305f\u3002 \u753b\u9762\u3092\u69cb\u6210\u3059\u308b\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8 \u3060\u3044\u305f\u3044\u3053\u3093\u306a\u30a4\u30e1\u30fc\u30b8\u3067\u30fb\u30fb\u30fb index.android.js \u3084 index.ios.js \u3067\u3000\u3053\u308c\u3089\u3092\u542b\u3093\u3060 View\u3092\uff11\u3064\u30ec\u30f3\u30c0\u30ea\u30f3\u30b0\u3057\u3066\u3084\u308b \u3088\u3046\u306a\u30a4\u30e1\u30fc\u30b8\u3067\u3059\u3002 \u30c7\u30d0\u30a4\u30b9\u306e\u5411\u304d\u306e\u5909\u5316\u3092\u6349\u3048\u308b \u3053\u308c\u3001 View\u306b onLayout\u3068\u3044\u3046\u30a4\u30d9\u30f3\u30c8\u304c\u3042\u308a\u307e\u3059\u306e\u3067\u3001\u3053\u3044\u3064\u3092\u4f7f\u3044\u307e\u3059\u3002 \u3053\u3044\u3064\u3068\u3001Dimensions\u304b\u3089\u6c42\u3081\u3089\u308c\u308b\u30c7\u30d0\u30a4\u30b9\u306e\u753b\u9762\u30b5\u30a4\u30ba\u3092\u7d44\u307f\u5408\u308f\u305b\u3066\u3001 \u30d8\u30c3\u30c0\u30fc\u30fb\u30d5\u30c3\u30bf\u30fc\u30fb\u30e1\u30a4\u30f3\u30b3\u30f3\u30c6\u30f3\u30c4\u306e\u9ad8\u3055\u3092\u8a08\u7b97\u3057\u307e\u3059\u3002 \u305d\u308c\u3092 setState\u306a\u3093\u304b\u3092\u4f7f\u3063\u3066\u3001\u8a2d\u5b9a\u3057\u3066\u3042\u3052\u3066\u3001\u753b\u9762\u3092\u518d\u63cf\u753b\u3059\u308c\u3070OK\u3067\u3059\u3002 \u65e5\u672c\u8a9e\u3067\u66f8\u304f\u3068\u3042\u3063\u3055\u308a\u3057\u3066\u307e\u3059\u304c\u3001\u5b9f\u969b\u5b9f\u88c5\u3059\u308b\u3068\u306a\u308b\u3068 \u305d\u308c\u306a\u308a\u306b\u30b3\u30fc\u30c9\u3092\u66f8\u304b\u306a\u304d\u3083\u306a\u308a\u307e\u305b\u3093\u3002 index.android.js \u306e\u4f8b [bash] import React from &#8220;react&#8221; import {View, Dimensions, Alert} from &#8220;react-native&#8221; \u301c\u3000\u4e2d\u7565\u3000\u301c handleLayoutChange(event) { let {height, width} = Dimensions.get(&#8220;window&#8221;) if (height > width) { Alert.alert(&#8220;\u7e26\u5411\u304d PORTRAIT&#8221;) } else{ Alert.alert(&#8220;\u6a2a\u5411\u304d LANDSCAPE&#8221;) } } render() { { this.handleLayoutChange(event) }}> } \u301c\u3000\u4e2d\u7565\u3000\u301c [\/bash] \u52d5\u4f5c\u30a4\u30e1\u30fc\u30b8 \u5b9f\u969b\u306b\u3046\u307e\u304f\u8a08\u7b97\u3067\u304d\u308b\u3068\u3001\u3053\u3093\u306a\u611f\u3058\u306b\u306a\u308a\u307e\u3059\u3002 \u3042\u3068\u304c\u304d React Native\u4ee5\u5916\u3067\u30b9\u30de\u30db\u5411\u3051\u306e\u30a2\u30d7\u30ea\u3092\u4f5c\u3063\u305f\u3053\u3068\u304c\u306a\u3044\u306e\u3067\u3001 \u5b9f\u969b\u306b\u3053\u3093\u306a\u30ed\u30b8\u30c3\u30af\u3092\u5b9f\u88c5\u3057\u306a\u3044\u3068\u3044\u3051\u306a\u3044\u306e\u304b\u3069\u3046\u304b\u3088\u304f\u5206\u304b\u3063\u3066\u304a\u308a\u307e\u305b\u3093\u3002\u3002 \u306a\u3093\u3067\u3001\u30d5\u30c3\u30bf\u30fc\u3092\u753b\u9762\u306e\u4e0b\u306b\u306f\u308a\u3064\u3051\u308b\u3053\u3068\u3050\u3089\u3044\u51fa\u6765\u306a\u3044\u3093\u3060\u3088\u30fb\u30fb\u30fb \u3068\u601d\u3044\u307e\u3059\u304c\u3001\u4eca \u8efd\u304f\u8abf\u3079\u305f\u611f\u3058\u3067\u306f\u3001\u65b9\u6cd5\u306f\u306a\u3055\u305d\u3046\u306a\u306e\u3067\u3001 \u30b4\u30ea\u30b4\u30ea\u8a08\u7b97\u3057\u3066\u6c42\u3081\u3061\u3083\u3046\u65b9\u6cd5\u304c\u3001\u4e00\u756a\u624b\u3063\u53d6\u308a\u65e9\u3044\u6c17\u304c\u3057\u307e\u3059\u3002 \u3082\u3063\u3068\u30b9\u30de\u30fc\u30c8\u306a\u65b9\u6cd5\u304c\u3042\u308c\u3070\u3001\u3058\u3083\u3093\u3058\u3083\u3093\u30b3\u30e1\u30f3\u30c8\u304f\u3060\u3055\u3044\u3002<\/p>\n","protected":false},"author":1,"featured_media":1643,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_uf_show_specific_survey":0,"_uf_disable_surveys":false,"footnotes":""},"categories":[77],"tags":[79,72],"class_list":{"0":"post-1641","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-react","8":"tag-react-native","9":"tag-reactjs"},"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/lovelinux.mydns.jp\/index.php?rest_route=\/wp\/v2\/posts\/1641","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lovelinux.mydns.jp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lovelinux.mydns.jp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lovelinux.mydns.jp\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lovelinux.mydns.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1641"}],"version-history":[{"count":1,"href":"https:\/\/lovelinux.mydns.jp\/index.php?rest_route=\/wp\/v2\/posts\/1641\/revisions"}],"predecessor-version":[{"id":1644,"href":"https:\/\/lovelinux.mydns.jp\/index.php?rest_route=\/wp\/v2\/posts\/1641\/revisions\/1644"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lovelinux.mydns.jp\/index.php?rest_route=\/wp\/v2\/media\/1643"}],"wp:attachment":[{"href":"https:\/\/lovelinux.mydns.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1641"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lovelinux.mydns.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1641"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lovelinux.mydns.jp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1641"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}