当 React Native 应用程序最初运行时,有一个白色的视图,如下面的屏幕截图,我该如何更改该视图的背景颜色?我在 Xcode 中找不到活动。
因为在某些情况下,我重新启动应用程序,并且用户看到一个闪光(上面的白屏),所以我需要更改背景颜色。
提前致谢。
我在我的项目中使用https://github.com/devfd/react-native-google-signin和https://github.com/luisfcofv/react-native-deep-linking包.我没有解决AppDelegate.m文件的以下部分,以便包可以工作.
对于这个反应原生谷歌登录
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
return [RNGoogleSignin application:application openURL:url
sourceApplication:sourceApplication annotation:annotation];
}
Run Code Online (Sandbox Code Playgroud)
对于这种反应原生深层连接
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
return [RCTLinkingManager application:application openURL:url
sourceApplication:sourceApplication annotation:annotation];
}
Run Code Online (Sandbox Code Playgroud)
我不擅长Objective-C.如何使用单个函数返回RNGoogleSignin和RCTLinkingManager?
我正在尝试使用AirBnb贴图(使用MapView.Markers)渲染一个按钮,我可以使用该按钮重定向到描述页面中的另一个页面(如果选择标记,则弹出框).我不知道如何实现这一目标.
目前我的标记如下:
const markers = [{
longitude: 8.545592,
latitude: 47.366465,
description: "Bike 1",
title: "Bike 1"
},
{
longitude: 8.545892,
latitude: 47.366365,
description: "Bike 2",
title: "Bike 2"
}
];
Run Code Online (Sandbox Code Playgroud)
每当我尝试将JSX输入到文本中时,我都会收到NSMutableDictionary cannot be converted to NSString错误.(当我这样做时:
const markers = [{
longitude: 8.545592,
latitude: 47.366465,
description: <Text>Bike1</Text>, //"Bike 1", //<Text> Bike1 </Text>
title: "Bike 1"
},
{
longitude: 8.545892,
latitude: 47.366365,
description: "Bike 2",
title: "Bike 2"
}
];
Run Code Online (Sandbox Code Playgroud) maps react-native airbnb-js-styleguide react-native-android react-native-ios
我想得到一个 json 文件作为回报。
这是我正在使用的提取函数
handleApi(){
return
fetch('https://facebook.github.io/react-native/movies.json')
.then((response) => response.json())
.then((responseJson) => {
return responseJson.movies;
})
}
Run Code Online (Sandbox Code Playgroud)
正在按钮单击事件上调用此函数。
handleSubmit() {
console.log(
this.handleApi();
)
Run Code Online (Sandbox Code Playgroud)
但我得到这个 Promise对象作为回报不是预期的数据
Promise {_40: 0, _65: 0, _55: null, _72: null}_40: 0_55: null_65: 0_72: null__proto__: Object
所以我从网络套接字连接接收文本,并将其添加到文本组件。它从灰色开始,然后在 x 时间后变成黑色(应用程序处理文本)。我有下面的代码
<Text style={styles.confirmedText}>
{this.state.confirmedText}
<Animated.Text style={{ fontFamily: "Helvetica Neue", color: "#9b9b9b" }}>
{this.state.tempText}
</Animated.Text>
</Text>
Run Code Online (Sandbox Code Playgroud)
所以这tempText是不断变化的,但我希望当文本从空字符串变为淡入动画时 -> 一些/任何文本。任何想法我怎么能做到这一点?
注意:我知道我的代码没有尝试实现这一点,但我无法使用 Animated.Text 找到任何工作示例。
提前致谢,
编辑:更好的是,如果 temp 的值是 say“some text”,并且添加了一个词,例如“some text plus”,那么添加的单独动画的词“plus”会很棒。虽然看起来很难
我是 react-native 的新手,我正在尝试在我创建的应用程序中使用滑动导航。我已经安装了 randomcolor 以及 native-react-swipe,但由于某种原因,我仍然收到错误消息。
import React, {Component} from 'react';
import Swiper from 'react-native-swiper'
import randomcolor from 'randomcolor'
const {
View,
Text,
StyleSheet
} = React
const styles = StyleSheet.create({
container: {
flex: 1
},
view: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
}
});
class TitleText extends React.Component {
render() {
return (
<Text style={{ fontSize: 48, color: 'white' }}>
{this.props.label}
</Text>
)
}
}
class Home extends React.Component {
viewStyle() {
return {
flex: 1,
backgroundColor: randomcolor(), …Run Code Online (Sandbox Code Playgroud) 嘿伙计们,我刚刚开始学习 React Native context api 我想知道我如何像全局状态一样全局实现它,并且在导航到另一个屏幕后它也不起作用,为什么我们在提供程序中包含类名<ProfileScreen screen= {this.state.contextData}/>我们可以全局执行.. 这是我的代码
global.cart=1
const Context = React.createContext(global.cart)
class HomeScreen extends Component<Props> {
constructor(props){
super(props);
this.state={
contextData:5
}
}
Incrementhome=()=>{
this.setState({contextData:global.cart})
global.cart++
}
Decrementhome=()=>{
this.setState({contextData:global.cart})
global.cart--
}
render() {
return (
<View>
<Context.Provider value={this.state.contextData}>
<Button title="Incrementhome"
onPress={this.Incrementhome}/>
<Button title="decrementhome"
onPress={this.Decrementhome}/>
<ProfileScreen screen= {this.state.contextData}/>
</Context.Provider>
<Button title='sd' onPress={()=>{this.props.navigation.navigate('Profile')}}/>
</View>
)
}
}
Run Code Online (Sandbox Code Playgroud)
可以显示我的数据的类配置文件屏幕
class ProfileScreen extends Component<Props> {
render() {
return (
<View style={{}}>
<Context.Consumer>
{data=> <Text style={{fontSize:50}}>{data}</Text>}
</Context.Consumer>
</View>
);
}
} …Run Code Online (Sandbox Code Playgroud) 使用 react-navigations - createBottomTabNavigator,我试图将图标向下推一点,但它被切断了,我不确定为什么。
有没有办法解决这个问题?或者如果你能指导我获得一些关于这方面的信息。
图标样式如下:
<Icon
name="heart"
color={tintColor}
size={28}
style={{ marginTop: '20' }}
/>
Run Code Online (Sandbox Code Playgroud)
这是标签栏选项:
tabBarOptions: {
showLabel: false,
activeTintColor: '#e91e63',
indicatorStyle: {
height: 100
},
style: {
position: 'absolute',
backgroundColor: 'transparent',
height: 50,
width: DEVICE_WIDTH * 0.94,
borderTopColor: 'transparent',
borderBottomLeftRadius: 33,
borderBottomRightRadius: 33,
borderTopLeftRadius: 10,
borderTopRightRadius: 10,
bottom: 0,
margin: 10,
shadowColor: '#000000',
shadowOffset: {
width: 0,
height: 0.3
},
shadowRadius: 5,
shadowOpacity: 0.1
},
tabStyle: {}
}
Run Code Online (Sandbox Code Playgroud)
提前谢谢了
react-native react-native-android react-native-ios react-navigation
android中的react native库可以使用“getCurrentActivity()”来代替“this”
final Activity activity = getCurrentActivity();
Run Code Online (Sandbox Code Playgroud)
而在 ios 中如何使用替换“self”来获取当前的 UIViewController
目标是通过一种简单干净的实施方式来构建一个类似于YouTube-App中的搜索过滤器的弹出窗口,请参见图片。轻按半透明的边框应关闭弹出窗口。应该从几个屏幕(在嵌套的导航结构内)调用同一弹出窗口,然后将选择返回给相应的屏幕。
我做了很多搜索和文档阅读,因此似乎有以下四个选择:
Alert窗口并大量修改警报消息,但是此选项不允许我通过单击透明区域来取消。react-native-popupwindow也不是一种选择。modal声称是在封闭视图上方显示内容的简单方法的组件。根据如何在本机模式中调暗背景?然后在模态外部点击以关闭模态(react-native-modal) “,这似乎是一个可能的选择。Overlay使用Modal,也只能将Modal作为最后的手段。请建议您在现实生活中测试了哪种解决方案。你有什么建议?也许有一个更简单的解决方案?
有关StackOverflow的相关问题: