小编ing*_*nga的帖子

FlatList在渲染时调用`onEndReached`

这是我简单的render()函数category list page.

最近我为我的FlatListView 添加了分页,所以当用户滚动到底部时,onEndReached在某个点(onEndReachedThreshold从底部开始的值长度)中调用,它将获取下一个categories并连接类别props.

但我的问题是在调用render()时调用 onEndReached.换句话说,FlatList onEndReached在它到达底部之前被触发.

我错了价值onEndReachedThreshold?你看到有什么问题吗?

return (
  <View style={{ flex:1 }}>
    <FlatList
      data={this.props.categories}
      renderItem={this._renderItem}
      keyExtractor={this._keyExtractor}
      numColumns={2}
      style={{flex: 1, flexDirection: 'row'}}
      contentContainerStyle={{justifyContent: 'center'}}
      refreshControl={
        <RefreshControl
          refreshing = {this.state.refreshing}
          onRefresh = {()=>this._onRefresh()}
        />
      }
      // curent value for debug is 0.5
      onEndReachedThreshold={0.5} // Tried 0, 0.01, 0.1, 0.7, 50, 100, 700

      onEndReached = {({distanceFromEnd})=>{ // problem
        console.log(distanceFromEnd) // 607, 878 
        console.log('reached'); // once, and …
Run Code Online (Sandbox Code Playgroud)

react-native

15
推荐指数
5
解决办法
2万
查看次数

App Transport Security通过自定义URL方案阻止路由

我的iOS应用程序(用Swift和React Native编写)有一个自定义url方案,允许我从例如Safari这样的appappscheme:// https://www.mywebsite.com/somematerial路由到应用程序.如果我在我的应用中启用App Transport Security,则会阻止通过自定义网址方案进行路由,并收到以下消息:

App Transport Security已阻止明文HTTP(http://)资源加载,因为它不安全.可以通过应用程序的Info.plist文件配置临时例外.

但是,如果我禁用ATS,应用程序将按预期路由.我没有通过我的应用程序中的http访问任何链接,在我的路由中,我总是通过https获取数据.因此,我不知道为什么ATS会阻止此路由.你知道我是否必须提供一些关于我的网址方案的其他信息吗?

请参阅Info.plist中的我的ATS配置:

<key>NSAppTransportSecurity</key>
<dict>
    <key>NSAllowsArbitraryLoadsInWebContent</key>
    <true/>
    <key>NSExceptionDomains</key>
    <dict>
        <key>localhost</key>
        <dict>
            <key>NSIncludesSubdomains</key>
            <true/>
            <key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>
            <true/>
        </dict>
    </dict>
</dict>
Run Code Online (Sandbox Code Playgroud)

我还将我的自定义网址列入白名单:

<key>LSApplicationQueriesSchemes</key>
<array>
    <string>myappscheme</string>
</array>
Run Code Online (Sandbox Code Playgroud)

url-scheme ios swift react-native

6
推荐指数
1
解决办法
619
查看次数

安装Cocoapods 0.35.0时出错

我正在尝试使用以下命令安装Cocoapods版本0.35.0:

sudo gem install cocoapods --version 0.35.0
Run Code Online (Sandbox Code Playgroud)

当我尝试验证版本时

pod --version
Run Code Online (Sandbox Code Playgroud)

我收到以下错误:

---------------------------------------------
Error loading the plugin with path `/Library/Ruby/Gems/2.0.0/gems/cocoapods-try-0.4.5/lib/cocoapods_plugin.rb`.

NoMethodError - undefined method `tmpdir' for Dir:Class
/Library/Ruby/Gems/2.0.0/gems/cocoapods-try-0.4.5/lib/pod/command/try.rb:66:in `<class:Try>'
/Library/Ruby/Gems/2.0.0/gems/cocoapods-try-0.4.5/lib/pod/command/try.rb:8:in `<class:Command>'
/Library/Ruby/Gems/2.0.0/gems/cocoapods-try-0.4.5/lib/pod/command/try.rb:5:in `<module:Pod>'
/Library/Ruby/Gems/2.0.0/gems/cocoapods-try-0.4.5/lib/pod/command/try.rb:4:in `<top (required)>'
/Library/Ruby/Site/2.0.0/rubygems/core_ext/kernel_require.rb:121:in `require'
/Library/Ruby/Site/2.0.0/rubygems/core_ext/kernel_require.rb:121:in `require'
/Library/Ruby/Gems/2.0.0/gems/cocoapods-try-0.4.5/lib/cocoapods_plugin.rb:1:in `<top (required)>'
/Library/Ruby/Site/2.0.0/rubygems/core_ext/kernel_require.rb:121:in `require'
/Library/Ruby/Site/2.0.0/rubygems/core_ext/kernel_require.rb:121:in `require'
/Library/Ruby/Gems/2.0.0/gems/claide-0.7.0/lib/claide/command/plugins_helper.rb:104:in `safe_require'
/Library/Ruby/Gems/2.0.0/gems/claide-0.7.0/lib/claide/command/plugins_helper.rb:32:in `block in load_plugins'
/Library/Ruby/Gems/2.0.0/gems/claide-0.7.0/lib/claide/command/plugins_helper.rb:31:in `each'
/Library/Ruby/Gems/2.0.0/gems/claide-0.7.0/lib/claide/command/plugins_helper.rb:31:in `load_plugins'
/Library/Ruby/Gems/2.0.0/gems/claide-0.7.0/lib/claide/command.rb:265:in `run'
/Library/Ruby/Gems/2.0.0/gems/cocoapods-0.35.0/lib/cocoapods/command.rb:45:in `run'
/Library/Ruby/Gems/2.0.0/gems/cocoapods-0.35.0/bin/pod:43:in `<top (required)>'
/usr/bin/pod:23:in `load'
/usr/bin/pod:23:in `<main>'
---------------------------------------------

0.35.0
Run Code Online (Sandbox Code Playgroud)

我试图卸载cocoapods和xcodeproj并重新安装它,但它不起作用.之前我还有其他三个类似的错误,但我已经摆脱了它们

sudo gem update --system
Run Code Online (Sandbox Code Playgroud)

不过,我无法修复最后一个错误.

ruby gem ios cocoapods

2
推荐指数
2
解决办法
1706
查看次数

如何让TalkBack忽略android:text元素?

我正在改进我的Android应用程序中的视障人士的可访问性.我在Android项目的popover.xml文件中有以下TextView.

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginBottom="12dp"
    android:text="@string/pass_code"/>
Run Code Online (Sandbox Code Playgroud)

每当我使用TalkBack测试应用程序时,应用程序会回拨字符串,android:text但在这种情况下,我根本不想要它被说出来,因为这是一个弹出窗口,所以我宁愿一旦窗口说出来砰的一声.所以我已经android:contentDescription="@string/pass_code"在我的根LinearLayout中说出了相同的字符串.

我试图设置android:contentDescription="@null",我也试过添加,tools:ignore="ContentDescription"但他们都没有工作.android:text中的元素总是被说出来.如何更改TextView,以便TalkBack将忽略android:text元素?

xml android accessibility textview talkback

0
推荐指数
1
解决办法
1553
查看次数