FlatList onRefresh不适用于SafeAreaView

时间:2019-04-15 18:36:12

标签: ios react-native react-native-flatlist safeareaview react-safeareaview

拉动刷新会导致不断旋转,并且在iPhone上测试应用程序时不调用onRefresh。在具有“主页”按钮的Android和iOS设备上,一切正常。

ReactNative版本:0.58.3

从容器样式中删除flex:1时,一切正常,但会破坏屏幕的降价幅度。使用ScrollView会导致相同的问题。

render() {
  return (
  <View style={styles.container}>
    <SafeAreaView style={styles.safeAreaView}>
      <Toolbar
        leftElement="menu"
        centerElement="sometext"
        style={{ container: { backgroundColor: '#ffa500' } }}
        searchable={{
          autoFocus: true,
          placeholder: 'Search',
          onChangeText: text => this.searchFilterFunction(text),
          onSearchCloseRequested: () => this.resetSearchFilter()
        }}
        onLeftElementPress={() => this.props.navigation.openDrawer()}
      />
    </SafeAreaView>

      <FlatList 
          data={this.state.data}
          keyExtractor={this.keyExtractor}
          ItemSeparatorComponent={this.renderSeparator}
          contentContainerStyle={{paddingLeft: '3%', paddingBottom: '4%'}}
          refreshing={this.state.refreshing}
          onRefresh={this.getData}
          renderItem={({item}) => 
            <PartnerCardComponent 
              partnerName={item.name} 
              discount={item.discount}
              url={item.url}
              image={item.image}
              phone={item.telephones}
              address={item.locations}
              description={item.description}
              navigation={this.props.navigation}
            />
          }
      />
      <SafeAreaView style={styles.bottomArea}/>
    </View>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: 'white'
  },
  safeAreaView: {
    backgroundColor: '#ffa500',
    shadowColor: 'gray',
    shadowOffset: {height: 1, width: 0},
    shadowOpacity: 0.5,
  },
  bottomArea: {
    backgroundColor: 'white',
    shadowColor: 'white',
    shadowOffset: {height: -5, width: 0},
    shadowOpacity: 5,
  }
});

预期:更新FlatList数据

正在接收:旋转器不断旋转,onRefresh不会调用。

1 个答案:

答案 0 :(得分:0)

我遇到了类似的情况(尽管我的FlatList在内部内,但没有被它们包围)。在我看来,对我有用的是使用一个模糊描述的RefreshControl组件,而不是直接设置onRefresh和刷新道具。没有看到其余的代码(以及从react-native导入RefreshControl),我只是将其放在以下位置:

'Set the parent folder

    myFolder = "C:\Users\Rocky\Desktop\Absences\"

'retrieve my subfolder using the directory function

    mySubFolder = Dir(myFolder & "*", vbDirectory)

'Make our macro run faster

      Application.ScreenUpdating = False

    Do While mySubFolder <> ""


       Select Case mySubFolder

         Case ".", ".." 

          Case Else

              collSubFolders.Add Item:=mySubFolder  
       End Select

'retrieve Next subfolder using the directory function 

          mySubFolder = Dir

    Loop 


'loop through each subfolders in my collection of subfolders


      For Each myItem In collSubFolders

'loop through excel workbooks in subfolders

      myFile = Dir(myFolder & myItem & "\*.xlsm*")

'within this loop nested a do while loop

     Do While myFile <> ""

'Open a workbook

      Set wbk = Workbooks.Open(Filename:=myFolder & myItem & "\" & myFile)

'Defining the lastrow before copying data

      lastrow = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row

'Defining the lastcolumn before copying data

     lastcolumn = ActiveSheet.Cells(1, Columns.Count).End(xlToLeft).Column


'we use the set keyword to create a new object

     Set copyRange = ActiveSheet.Range("C1,D45,D46,D47")


For Each cel In copyRange

    cel.Copy

'Once copy close workbook

      wbk.Close SaveChanges:=False 
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

      erow = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row 


      ActiveSheet.Cells(erow, 1).Select

       ActiveSheet.Paste

        ActiveWorkbook.Save

Next