1.ios的Text标签内的文字垂直居中:
父元素 height = 文字 fontSize + 文字 lineHeight;
2.navigator的,jumpTo方法
用getCurrentRoutes拿到所有的routes,jumpTo(routes[0])
3.手势相应触发方法规则
1)需要触发�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)} //只能执行到return之前
right:
onStartShouldSetResponder={this.handleShow(data)}
4.cocoapods导入RN问题
官网上Podfile文件内容是
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.不能局域网调试
在xcode下info.plist文件里修改
标签下添加
或者直接到xcode里点开info.plist设置
App Transport Security Settings
下添加
Allow Arbitrary Loads
值为YES
6.ios键盘挡住输入框
在项目ios文件夹下创建Podfile并编辑(前提是已经安装cocoapods)
platform :ios, '8.0' target 'AwesomeProject' do pod 'IQKeyboardManager', '~> 4.0.4' end
运行
pod install
这时会出现
[!] 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.设置npm淘宝镜像
1.打开.npmrc文件(在用户主目录下)
加入以下配置信息:
registry = http://registry.npm.taobao.org
2.在命令终端输入
npm config list
显示结果:
; 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.
设置镜像
npm config set registry " https://registry.npm.taobao.org "