我将滚动视图作为标题,列表视图作为Body.So,我必须在当前代码中以语法的方式在List swipe.so上滑动滚动视图,我正在获取滚动视图的id,在其中我需要实际使用的组件,可以调用该组件的scrollview.scrollTo();方法。
render() {
return (
<View style={styles.container}>
<View style={styles.scrollContainer}>
<ScrollView
ref={'abc'}
directionalLockEnabled={false}
horizontal={true}>
<View style={styles.scrollItemStyle}>
<Image source={shield} style={homescreenstyle.imagestyle}/>
</View>
<View style={styles.scrollItemStyle}>
<Image source={shield} style={homescreenstyle.imagestyle}/>
</View>
<View style={styles.scrollItemStyle}>
<Image source={shield} style={homescreenstyle.imagestyle}/>
</View>
<View style={styles.scrollItemStyle}>
<Image source={shield} style={homescreenstyle.imagestyle}/>
</View>
<View style={styles.scrollItemStyle}>
<Image source={shield} style={homescreenstyle.imagestyle}/>
</View>
<View style={styles.scrollItemStyle}>
<Image source={shield} style={homescreenstyle.imagestyle}/>
</View>
<View style={styles.scrollItemStyle}>
<Image source={shield} style={homescreenstyle.imagestyle}/>
</View>
</ScrollView>
</View>
<View style={styles.listcontainer}>
<ListView
dataSource={this.state.todaysData}
renderRow={this.renderRow}
onScroll={this.handleScroll}
style={styles.container}
/>
</View>
</View>
);
}
renderRow(rowData){
return (
<CustomListRowCards
title={rowData.title}/>
);
}
handleScroll(event: Object) {
// var input = this.refs.scrollview;
customViewNativeID.scrollTo(500, 0, true)
// alert(event.nativeEvent.contentOffset.y);
}//CutomViewNativeId返回id..But,我需要视图actually.Actually,我正在寻找像android中的findViewById()这样的东西,我是一个android开发人员,我是一个新的反应-原生的…请提前suggest.Thank你
发布于 2017-09-25 19:16:38
为了访问任何视图,您通常会执行如下操作:
class MyComponent extends React.Component {
viewOne = null
//state = {...}
useViewOne = () => {
this.viewOne.doSomething()
}
render() {
return (
<View ref={(viewRef) => this.viewOne = viewRef}>
</View>
)
}
}请记住,this.viewOne在componentWillMount()中是空的,您应该在componentDidMount()中使用它。
https://stackoverflow.com/questions/46406966
复制相似问题