My TextInput is missing inside ScrollView for iOS. It works fine on android.
Included is the sample app using Playground.
https://rnplay.org/apps/KtTZ2g
You could see that android is showing the TextInput, but the iOS's one does not show it.
These kind of bugs is making me crazy...
When using the TextInput, be sure to provide a height:
<TextInput
style={{flex: 1, color: 'black', height:40}}
editable={false}
defaultValue="+"
underlineColorAndroid='#C8C7CC' />
https://rnplay.org/apps/a6i08w
Related
I'm working on a small react-native app. It's nearly only a container for showing my webapp, so nearly everthing is running cool.
The problem is, the user needs to rotate the screen on some of the webapp-sites. With my implementation this works very good on android, but not on iOS. The funny thing is, when I start the app on iOS via EXPO GO, it also works.
I've searched a lot but I can not find a solution for this. Do you have any idea how to change that behavior on iOS?
This is my App.js
import React from "react";
import { StyleSheet, View } from "react-native";
import WebView from 'react-native-webview';
const WEBSITE = 'https://www.google.com'
export default function App() {
return (
<View style={styles.container}>
<View style={{ width: '100%', height: '100%' }}>
<WebView
source={{ uri: WEBSITE }}
/>
</View>
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: "flex-start",
alignItems: "flex-start",
},
});
I would first check your xcode project settings and ensure that the orientations you are looking for are enabled. If you open up xcode and check the orientations you should have all the orientations selected that you want to support. The project below has only portrait enabled therefore I'd suggest you enable the landscape orientations and hopefully this should resolve your problem.
I am developing a react-native app using expo.
On my signIn screen I do have two TextInputs (with textContentType username and password).
I do have multiple places where I'm calling Keyboard.dismiss() (from a wrapping Touchable, from other Buttons etc.) which works fine for most usecases.
My problem is that after I successfully used password autofill on iOS (via fingerprint) first the keyboard hides and reshows automatically (fireing all the usual keyboard events) which looks strange but is acceptable but afterwards the keyboard is no longer reacting to any Keyboard.dismiss() calls untill I focus another TextInput.
There seems to be a similar issue with the "use strong password" keyboard overlay.
Here my versions:
"expo": "^34.0.1",
"react": "16.8.3",
"react-dom": "^16.8.6",
"react-native": "https://github.com/expo/react-native/archive/sdk-34.0.0.tar.gz",
Running in the Expo client on iOS 13.2.3
Thank you in advance for any help.
Edit:
I stripped down the problem to the most basic version. The dismiss button works fine untill I use the password autofill on the iOS device.
https://github.com/SebastianRoese/tryouts/tree/master/keyboard-dismiss-problem
import React from 'react'
import { View, Button, TextInput, StyleSheet, Keyboard } from 'react-native'
const App = () => {
return (
<View style={styles.screen}>
<TextInput style={styles.textinput} textContentType="username" />
<TextInput style={styles.textinput} secureTextEntry textContentType="password" />
<Button title="Dismiss Keyboard" onPress={() => Keyboard.dismiss()} />
</View>
)
}
const styles = StyleSheet.create({
screen: {
width: '100%',
height: '100%',
paddingVertical: '15%',
backgroundColor: '#1e1e1e',
alignItems: 'center',
},
textinput: {
marginVertical: 10,
padding: 10,
width: '70%',
height: 40,
backgroundColor: '#ababab',
},
})
export default App
After upgrading from Expo SDK 34 to Expo SDK 38 the problem is no longer reproducable.
Seems like it was an issue in al least Expo SDK Version 34.
is it possible, to show animated GIFs with - source={require(...)} on iOS with React-Native?
The following example do not work:
<ImageBackground source={require(...)} style={{width:'100%',height:'100%'}} />
This Example works:
<Image source={{uri: 'https://media.giphy.com/media/JQ3IMbDi5Jkw8/giphy.gif'}} style={{width:'100%',height:'100%'}} />
I will use ImageBackground with "require" to show an animated GIF on IOS.
Everything works on Android.
I hope someone can help me.
OfCourse, it will also work on IOS. You can test it by using https://snack.expo.io
Here is using ImageBackground component in IOS.
I'm trying to implement two text inputs. I'm not sure if the best practice is to wrap these inside a scroll view or not. However, when I do it as shown below, I just see a single line in the middle.
If I remove the scroll view and just leave a single Text Input, it displays a box with input that I can interact with. Though I'm still unable to get the keyboard to display on the simulator. But I can manually type in and change state.
Any idea on how to allow more than one text input, as well as how to show the native keyboard that pops up from the bottom?
render() {
return (
<ScrollView>
<TextInput
style={{height: 40, borderColor: 'gray', borderWidth: 1}}
placeholder="Enter item 1"
value={this.state.text}
onChangeText={this.onChange} />
<TextInput
style={{height: 40, borderColor: 'gray', borderWidth: 1}}
placeholder="Enter item 2"
value={this.state.text}
onChangeText={this.onChange} />
</ScrollView>
);
}
1 - For the iOS Simulator there is an option Hardware -> Keyboard -> Toggle Software Keyboard (which is unchecked by default). Checking this option should solve your issue of displaying the native keyboard.
2 - Regarding multi-line text input. Yes this is an issue, but there is a work around shared in this answer below. I'll attach the link to the answer for your reference.
P.s: I haven't tried it myself, but the answer has been marked to have solved the issue!
Multi-Line TextInput Hack - https://stackoverflow.com/a/31759113/5783646
Display keyboard in iOS Simulator: Hardware -> Keyboard -> Toggle Software Keyboard
Show more than one text input: My guess is that there are styles applied (or not applied) to a parent element or elsewhere that is preventing the TextInput from rendering at a useable size.
I created an example on RN Playground that demonstrates what you are asking for: https://rnplay.org/apps/ldlfWw
I am facing something weird issue with React-Native's <Text/> component in iOS.
I wanted to apply borderBottomWidth style into <Text/> component but it did NOT work. However, the borderWidth option worked.
Worked
<Text style={{borderWidth:1}}> React Native </Text>
NOT Worked
<Text style={{borderBottomWidth:1}}> React Native </Text>
Is there any way to only apply bottom level border into the <Text/> component?
Thank you!
Note:
I am aware of following mentioned approaches in order to achieve this but in my case, I required to apply the style only to the <Text/> component.
We can try wrapping <View/> to the <Text/> and apply borderBottomWidth style to the <View/>. (borderBottomWidth works fine with <View/>)
Adding such <View/> just below to the <Text/> component which can look like a line.
Even though borderBottom doesn't work on the Text component, it did work for me on the TextInput component, just set editable to false and set the value to your desired text as so...
<TextInput
style={styles.textInput}
editable={false}
value={'My Text'}/>
const styles = StyleSheet.create({
textInput: {
borderBottomColor: 'black',
borderBottomWidth: 1,
}
});
This isn't currently possible. See the following RN issue: https://github.com/facebook/react-native/issues/29 and this ticket on Product Pains: https://productpains.com/post/react-native/add-borderwidth-left-right-top-bottom-to-textinput-/
We can now use :
const styles = StyleSheet.create({
textZone: {
borderTopRightRadius: 10,
borderTopLeftRadius: 10,
borderBottomRightRadius: 10,
borderBottomLeftRadius: 10
},
})