在React Native中如何在会话中存储值?
我需要在会话中存储登录详细信息(用户名,密码).
你能提出任何想法吗?
我想在我的React-Native应用程序的底部有一个导航栏和每个页面顶部的工具栏.但是,如果我在index.ios.js文件中创建这两个元素,我会收到错误:"相邻的JSX元素必须包装在一个封闭的标记中".如果我在Navigator和NavBar周围放置标签,我只会在我的应用中看到一个空白屏幕.我该怎么办?这是我的render函数在index.ios.js中的样子
render() {
return (
<Navigator
initialRoute={{name: 'Login'}}
renderScene={this.renderScene}
navigationBar={
<Navigator.NavigationBar
style={ styles.nav }
routeMapper={ NavigationBarRouteMapper } />
}
/>
<NavBar />
);
}Run Code Online (Sandbox Code Playgroud)
我有一个TabNavigator,如图所示. 标题图片
我正在使用TabNavigator创建这些选项卡,如下所示.
const Tab_Navigator = TabNavigator({
First:{
screen: First,
},
Second:{
screen: Second,
},
Third:{
screen: Third,
},
Run Code Online (Sandbox Code Playgroud)
现在我想阻止/禁用"第二"和"第三"选项卡.它应该是可见的,但是人们不应该导航到它们.
我尝试阻止这些显示,如我所示,但我想我错过了一些东西.我的尝试:
Tab_Navigator.router.getStateForAction = (action, state) => {
if( action.type === NavigationActions.navigate({ routeName: "Second"}) ||
action.type === NavigationActions.navigate({ routeName: "Third"}))
{
return null;
}
return Byte.router.getStateForAction(action, state);
Run Code Online (Sandbox Code Playgroud)
};
tabnavigator react-native react-native-android react-native-ios react-navigation
通过react导航,StackNavigator,简单的标题被包装了。如何显示完整标题?在下面的代码中,标题为“个人信息”。但是标题未在iPhone 5s设备和模拟器上完整显示。
版本:
“ react-native”:“ ^ 0.47.2”
静态navigationOptions = {title:“个人信息”};
我有一个一般性问题和两个更具体的问题.
所有关于忽略特定警告的React-Native文档都说:
"通过使用console.disableYellowBox = true;可以在开发期间禁用YellowBoxes.通过设置应忽略的前缀数组,可以以编程方式忽略特定警告:console.ignoredYellowBox = ['Warning:...'] ;."
所以React-Native提供了这段代码,但我不知道如何指定警告的名称:
console.ignoredYellowBox = ['Warning: ReactNative.createElement'];
Run Code Online (Sandbox Code Playgroud) javascript reactjs react-native react-native-android react-native-ios
我试图在iOS的react-native应用程序中将截图保存到Camera Roll,但是一旦调用CameraRoll.saveToCameraRoll,应用程序就会崩溃.它一直工作到iOS 10并且反应原生0.47.它在Android中运行得非常好.
我已经拥有Info.plist中iOS 10+所需的权限.
这是我将图像保存到相机胶卷的代码.
CameraRoll.saveToCameraRoll(mUri, 'photo')
.then(()=>console.log('saved to CameraRoll'))
.catch(()=>console.log('error in saving'))
Run Code Online (Sandbox Code Playgroud)
请注意,我没有得到任何上述两个控制台日志.这是一个本机崩溃,下面是崩溃线程.
Thread 39 Queue : com.apple.root.default-qos (concurrent)
#0 0x000000010c8280aa in __abort_with_payload ()
#1 0x000000010c824326 in abort_with_payload_wrapper_internal ()
#2 0x000000010c82434f in abort_with_payload ()
#3 0x000000010c9d2b09 in __CRASHING_DUE_TO_PRIVACY_VIOLATION__ ()
#4 0x000000010c9d2a53 in __TCCAccessRequest_block_invoke.77 ()
#5 0x000000010c9d6273 in __tccd_send_block_invoke ()
#6 0x000000010c76ead5 in _xpc_connection_reply_callout ()
#7 0x000000010c76417c in _xpc_connection_call_reply_async ()
#8 0x000000010c39f49e in _dispatch_client_callout3 ()
#9 0x000000010c3b7658 in _dispatch_mach_msg_async_reply_invoke ()
#10 0x000000010c3a407d in _dispatch_queue_override_invoke ()
#11 0x000000010c3ab1f9 in _dispatch_root_queue_drain …Run Code Online (Sandbox Code Playgroud) 我想在我的项目中安装SafeAreaView以适应iPhone X屏幕,我不想将react-native版本升级到包含SafeAreaView组件的0.50.1,现在我的react-native版本是0.48.0,还有一个仅限JS版本的npm模块,react-native-safe-area-view.
我装了它
npm install react-native-safe-area-view --save
然后我用xcode运行我的项目,它显示错误
错误:捆绑失败:模糊解析:模块/Users/dongfanggouwu-xiong/WebstormProjects/untitled/index.js尝试要求react-native,但有几个文件提供此模块.您可以删除或修复它们:
/Users/dongfanggouwu-xiong/WebstormProjects/untitled/node_modules/react-native-safe-area-view/node_modules/react-native/package.json/Users/dongfanggouwu-xiong/WebstormProjects/untitled/node_modules/react-native/package.json有两个react-native模块,一个是react-native-safe-area-view,我不知道如何解决它,我浪费了很多时间,并尝试了很多方法来找到解决方案.
那么有没有人对我的反应原生的iPhone X适应有同样的问题?
试图复制以下设计但不能.将不胜感激任何帮助.
我尝试过的代码如下所示,但该行会覆盖文本.
<View>
<View style={{ alignSelf:'center', borderBottomColor:'black', borderBottomWidth:1,height:'50%', width:'90%' }}/>
<Text style={{ alignSelf:'center', paddingHorizontal:5 }}>Your class</Text>
</View>
Run Code Online (Sandbox Code Playgroud) 我无法从React Native应用程序打开iOS画廊应用程序。我有文件网址和资产网址。我从CameraRoll获取了资源网址。现在,我想打开图库本身以查看图像。
这是我使用的代码
openGallery = () => {
// this code is working on android using asset url
// sample url on iOS
// file url : file:///var/mobile/Containers/Data/Application/A41FFC2E-06D4-445D-9B94-D21E885930C7/Documents/video/popcam-1527202811.mov
// asset url : assets-library://asset/asset.mov?id=D4C62335-EDB1-4A75-B94D-61C3D48CADEA&ext=mov
const { galleryUrl, source } = this.props
const url = Platform.OS === 'ios' ? source : galleryUrl
Linking.canOpenURL(url).then(canOpen => {
if (canOpen) {
Linking.openURL(url)
} else {
Alert.alert('Info', 'Under Development')
}
})
Run Code Online (Sandbox Code Playgroud)
谢谢
我已经用于react-native-webview呈现HTML文本。但是在iOS中文本太小,而在android中则太完美了。
以下是代码行:
import { WebView } from "react-native-webview";
render() {
<WebView
originWhitelist={['*']}
source={{ html: '<p>This is a static HTML source!</p>' }}
/>
}
Run Code Online (Sandbox Code Playgroud)
附屏幕截图:
react-native ×10
react-native-ios ×10
ios ×3
camera-roll ×1
deep-linking ×1
facebook ×1
ios11 ×1
iphone ×1
javascript ×1
jsx ×1
reactjs ×1
tabnavigator ×1