小编L88*_*887的帖子

React Native中的模态视图

我是新来回应原生,我试图以模态呈现一个视图.我有一个表视图,当单击其中一行时,我希望视图以模态方式显示.

这就是我现在实现转换的方式:

renderbooks(books) {
     return (
          <TouchableHighlight onPress={() => this.showbooksDetail(books)}  underlayColor='#dddddd'>
              <View>
                  <View style={styles.container}>

                      <View style={styles.rightContainer}>
                          <Text style={styles.title}>{books.title}</Text>



                          </View>
                  </View>
                  <View style={styles.separator} />
              </View>
          </TouchableHighlight>
     );
 }
 showbooksDetail(books){
   this.props.navigator.push({
     title:books.title,
     component: ProductView,
     passProps:{books}
   });
 }
Run Code Online (Sandbox Code Playgroud)

如何修改此视图以便以模态方式呈现视图?

仅供参考:我已经查看了多个问题和示例项目,例如:

react-native

8
推荐指数
1
解决办法
2万
查看次数

计算从 1 到 N 的整数中 1 的总数

问题陈述:

给定一个整数n,计算所有小于或等于n的非负整数中出现的数字1的总数。

例如:给定 n = 13,返回 6,因为数字 1 出现在以下数字中:1、10、11、12、13。

有效的解决方案:

int countDigitOne(int n) {
    if (n <= 0) return 0;
    int q = n, x = 1, ans = 0;
    do {
        int digit = q % 10;
        q /= 10;
        ans += q * x;
        if (digit == 1) ans += n % x + 1;
        if (digit >  1) ans += x;
        x *= 10;
    } while (q > 0);
    return ans;
}
Run Code Online (Sandbox Code Playgroud)

我的问题:

我在其中一个论坛中找到了该问题的解决方案,但我发现很难理解该解决方案。我明白这是一个非常简单的,但请详细解释帮助我。

谢谢

algorithm math

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

标签 统计

algorithm ×1

math ×1

react-native ×1