0

我正在开发 flex 移动应用程序,并且正在使用 StageWebView 类来显示格式化的 html 内容。我遇到的唯一问题是,当我在移动设备上查看我的应用程序时,我没有任何滚动条,因此我可以向上或向下移动以查看我的 html 的内容。

请注意,我的 html 文件包含格式化的文本、图像和超链接。

有没有办法显示滚动条?

或者在我的手机上显示此类数据的任何其他更好的方式,除了 StageWebView?

提前致谢。

4

1 回答 1

0

您确定您的 StageWebView 具有正确的尺寸(宽度和高度)吗?

这里是一个使用 StageWebView 显示使用帮助的应用程序的视图:

<?xml version="1.0" encoding="utf-8"?>
<s:View xmlns:fx="http://ns.adobe.com/mxml/2009" 
        xmlns:s="library://ns.adobe.com/flex/spark" 
        viewActivate="openSWV(event)"
        viewDeactivate="closeSWV(event)"
        title="Help">

    <s:states>
        <s:State name="portrait"/>
        <s:State name="landscape"/>
    </s:states> 

    <s:navigationContent>
        <s:Button label="Back" click="navigator.popView()"/>
    </s:navigationContent>

    <fx:Declarations>
        <fx:String id="_help">
            <![CDATA[
<html>
<body>

<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>

<ul>
<li>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</li>
<li>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</li>
<li>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</li>
<li>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</li>
</ul>


<table border=1 width=100%>
<tr bgcolor="#CCCCCC">
<th>Blah</th><th>Blah</th><th>Blah</th><th>Blah</th>
</tr>

<tr>
<th>6</th><td>2</td><td>4</td><td>2</td>
</tr>
<tr>
<th>7</th><td>4</td><td>2</td><td>1</td>
</tr>
<tr>

<th>8</th><td>6</td><td>1*</td><td>1</td>
</tr>
<tr>
<th>Blah</th><td>10</td><td>-</td><td>-</td>
</tr>
<tr>
<th>9</th><td>8</td><td>1*</td><td>1</td>

</tr>
<tr>
<th>10</th><td>10</td><td>0</td><td>0</td>
</tr>
</table>

<p><i>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</i></p>

</body>
</html>
            ]]>
        </fx:String>
    </fx:Declarations>

    <fx:Script>
        <![CDATA[
            import mx.core.FlexGlobals;
            import mx.events.FlexEvent;
            import flash.media.StageWebView;

            private var _swv:StageWebView;

            private function openSWV(event:Event=null):void {
                _swv = new StageWebView();
                stage.addEventListener(Event.RESIZE, resizeSWV);

                _swv.stage = stage;
                resizeSWV();

                _swv.loadString(_help);
            }

            private function closeSWV(event:Event=null):void {
                stage.removeEventListener(Event.RESIZE, resizeSWV);
                if (! _swv)
                    return;
                _swv.dispose();
                _swv = null;
            }           

            private function resizeSWV(event:Event=null):void {
                if (! _swv)
                    return;

                var scale:Number = scale = runtimeDPI / applicationDPI;
                // align to the right-bottom corner
                _swv.viewPort = new Rectangle(stage.stageWidth - scale * width, stage.stageHeight - scale * height, scale * width, scale * height);
            }
        ]]>
    </fx:Script>
</s:View>

它可以在 Android、iOS 和 BB10 上显示滚动条...

于 2014-02-04T11:46:31.557 回答