1.ios的Text標(biāo)簽內(nèi)的文字垂直居中:
父元素 height = 文字 fontSize + 文字 lineHeight;
2.navigator的,jumpTo方法
用getCurrentRoutes拿到所有的routes,jumpTo(routes[0])
3.手勢相應(yīng)觸發(fā)方法規(guī)則
1)需要觸發(fā)?state:
changeToMenu() { Animated.timing( this.state.fadeAnim, { toValue: 1, duration: 1000 } ).start() }
error:
onStartShouldSetResponder={this.changeToMenu}
right:
onStartShouldSetResponder={() => this.changeToMenu()}
或
onStartShouldSetResponder={this.changeToMenu.bind(this)}
2) 閉包傳值
handleShow(data) { return (function () { console.log(data) } }
error:
onStartShouldSetResponder={() => this.handleShow(data)} //只能執(zhí)行到return之前
right:
onStartShouldSetResponder={this.handleShow(data)}
4.cocoapods導(dǎo)入RN問題
官網(wǎng)上Podfile文件內(nèi)容是
pod 'React', :path => './node_modules/react-native', :subspecs => [ 'Core', 'RCTImage', 'RCTNetwork', 'RCTText', 'RCTWebSocket' ]
這是低版本cocoapods的寫法
cocoapods的1.0.0以上的版本是
target 'EmbededRNExample' do pod 'React', :path => './node_modules/react-native', :subspecs => [ 'Core', 'RCTImage', 'RCTNetwork', 'RCTText', 'RCTWebSocket', ] end
5.不能局域網(wǎng)調(diào)試
在xcode下info.plist文件里修改
<key>NSAppTransportSecurity</key>
標(biāo)簽下添加
<key>NSAllowsArbitraryLoads</key> <true/>
或者直接到xcode里點開info.plist設(shè)置
App Transport Security Settings
下添加
Allow Arbitrary Loads
值為YES
6.ios鍵盤擋住輸入框
在項目ios文件夾下創(chuàng)建Podfile并編輯(前提是已經(jīng)安裝cocoapods)
platform :ios, '8.0' target 'AwesomeProject' do pod 'IQKeyboardManager', '~> 4.0.4' end
運行
pod install
這時會出現(xiàn)
[!] The `AwesomeProject [Debug]` target overrides the `OTHER_LDFLAGS` build setting defined in `Pods/Target Support Files/Pods-AwesomeProject/Pods-AwesomeProject.debug.xcconfig'. This can lead to problems with the CocoaPods installation
- Use the `$(inherited)` flag, or
- Remove the build settings from the target.
打開項目的 Target -> Build Settings -> Other linker flags -> 添加 $(inherited)
7.設(shè)置npm淘寶鏡像
1.打開.npmrc文件(在用戶主目錄下)
加入以下配置信息:
registry = http://registry.npm.taobao.org
2.在命令終端輸入
npm config list
顯示結(jié)果:
; cli configs
user-agent = "npm/2.15.8 node/v4.4.7 darwin x64"
; node bin location = /usr/local/bin/node
; cwd = /Users/macbook
; HOME = /Users/macbook
; 'npm config ls -l' to show all defaults.
設(shè)置鏡像
npm config set registry " https://registry.npm.taobao.org "