【问题标题】:How to avoid pulling down of screen on iPhone app如何避免在 iPhone 应用程序上拉下屏幕
【发布时间】:2014-03-27 09:02:48
【问题描述】:

我正在为 iPhone 开发一个应用程序,但如果我用手指拖动,我的应用程序屏幕可以上下拉动。我希望页眉和页脚保持固定,并且可以向上和向下拉动页面内容。而且还想换屏后下拉和上拉应该是灰色而不是黑色。我正在使用带有cordova(phonegap)的xcode5。请帮忙。
谢谢你。

【问题讨论】:

    标签: jquery ios css iphone cordova


    【解决方案1】:

    如果您使用的是 Cordova 2.3.0+,请找到 config.xml 并添加以下行:

      <preference name="UIWebViewBounce" value="false" />
    

    或在 Cordova 2.6.0+ 中:

      <preference name="DisallowOverscroll" value="true" />
    

    【讨论】:

    • 谢谢@milind,我会尽力让你知道。知道如何将屏幕下方的黑色更改为屏幕中的灰色吗?
    • @Sushant:这将防止拉屏幕。如果我能得到一些关于颜色变化的信息,我会告诉你的。
    • @Sushant:很高兴它有帮助:)
    【解决方案2】:

    如果你使用 phonegap 3 + 然后添加

      <preference name="DisallowOverscroll" value="true" />
    

    到 config.xml

    【讨论】:

    • 成功了!!!!谢谢@Arjun。工作!你现在能告诉我修复灰色背景的标题和可移动内屏吗
    • 使用css溢出属性,
    【解决方案3】:

    在您的应用程序 config.xml 文件中完成下一行: - DisallowOverscroll ->> true - 删除 html(Cordoba 文件)中的任何元标记,例如 height=device-height。 对于背景黑色,看看这是否有帮助:phonegap ios7 select dropdown gets black background

    【讨论】:

      【解决方案4】:

      在你的代码中试试这个

      <div data-role="footer" data-position="fixed" data-tap-toggle="false">
      

      希望这会有所帮助

      【讨论】:

        【解决方案5】:

        尝试以下脚本,您的问题将得到解决。

        // Function to disable "pull-to-refresh" effect present in some webviews.
        // Especially Crosswalk 12 and above (Chromium 41+) runtimes.
        window.addEventListener('load', function() {
            var lastTouchY = 0;
            var maybePreventPullToRefresh = false;
        
            // Pull-to-refresh will only trigger if the scroll begins when the
            // document's Y offset is zero.
        
            var touchstartHandler = function(e) {
                if (e.touches.length != 1) {
                    return;
                }
                lastTouchY = e.touches[0].clientY;
                // maybePreventPullToRefresh = (preventPullToRefreshCheckbox.checked) && (window.pageYOffset == 0) ;
        
                maybePreventPullToRefresh = (window.pageYOffset === 0);
                //document.getElementById('txtLog').textContent = "maybePreventPullToRefresh: " + maybePreventPullToRefresh;
            };
        
            // To suppress pull-to-refresh it is sufficient to preventDefault the
            // first overscrolling touchmove.
        
            var touchmoveHandler = function(e) {
                var touchY = e.touches[0].clientY;
                var touchYDelta = touchY - lastTouchY;
                lastTouchY = touchY;
        
                if (maybePreventPullToRefresh) {
                    maybePreventPullToRefresh = false;
                    //if (touchYDelta > 0) {
                    e.preventDefault();
                    //document.getElementById('txtLog').textContent = "TouchY: " + touchYDelta;
                    // console.log("pull-to-refresh event detected") ;
                    return;
                    //}
                }
        
                // if (preventScrollCheckbox.checked) {
                //     e.preventDefault() ;
                //     return ;
                // }
        
                // if (preventOverscrollGlowCheckbox.checked) {
                //     if (window.pageYOffset == 0 && touchYDelta > 0) {
                //         e.preventDefault() ;
                //         return ;
                //     }
                // }
            };
        
        
        
            document.addEventListener('touchstart', touchstartHandler, false);
        
            document.addEventListener('touchmove', touchmoveHandler, false);
        
        });
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 2011-10-10
          • 1970-01-01
          • 2014-08-10
          • 2011-10-24
          • 2013-05-02
          • 2012-01-23
          • 1970-01-01
          相关资源
          最近更新 更多