Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
598 views
in Technique[技术] by (71.8m points)

react native - navigation.setOptions not working on ios but working on android

i am having a strange problem where i am able to set custom option in android but same thing is not working in ios. here is my code which set the header:

         navigation.setOptions(
                {
                    headerTitle: (props) => <StoreHeader title={route.params.name} phoneNumber = {route.params.storePhoneNumber} address={route.params.storeAddress} ></StoreHeader>,
                }
            ); 

it works well in android but does not work in ios. look at the screenshot below (iphone does not get the StoreHeader component rendered at all):

enter image description here

Code for storeheader component is as follows:

export function StoreHeader(props) {
    return (
        <View style={{flexDirection:"row"}}>
            <View style={{flex:0.8, justifyContent:"center", alignItems:"center"}}>
            <Text style={{fontSize:20, fontWeight:"bold"}}>{props.title}</Text>
            <Text style={{fontSize:10}}>{props.address}</Text>
            </View>
            <View style={{flex:0.2, justifyContent:"center", alignItems:"center"}}>
            <TouchableOpacity onPress={async () => {console.log(props.phoneNumber);await Linking.openURL(`tel:${props.phoneNumber}`);}}> 
                    <Ionicons name="call-outline" size={40} color="green" ></Ionicons>
            </TouchableOpacity>
            </View>
        </View>
    );
}
question from:https://stackoverflow.com/questions/65600268/navigation-setoptions-not-working-on-ios-but-working-on-android

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...