phonegap(3+) Hybrid开发,问题and解决。(更新)

一、

现象:

IOS app中,点击按钮【A】,弹出dialog【B】(jqmobi af.popup插件),【B】中有按钮【C】;【A】和【C】Z轴重合。点击【A】时,popup出【B】,立即触发了【C】的动作。


解决:试图用e.stopPropagation()去禁止【A】冒泡,失败。然后想到了用CSS来解决。

添加样式:

<span style="font-size:14px;"><span style="font-size:14px;"><span style="font-size:18px;"><span style="font-size:14px;">.afPopup.prevent-events input, .afPopup.prevent-events textarea, .afPopup.prevent-events a {
	pointer-events: none;
}</span></span></span></span>


在【B】刚加入到DOM的时候,给【B】的根DIV添加样式prevent-events来禁止【B】接受事件。

<span style="font-size:14px;"><span style="font-size:14px;"><span style="font-size:18px;"><span style="font-size:14px;">$('B的[DIV]').addClass('prevent-events');</span></span></span></span>

 

然后setTimeout来删除该样式。

<span style="font-size:14px;"><span style="font-size:14px;"><span style="font-size:18px;"><span style="font-size:14px;">setTimeout(function(){
                	$('B的[DIV]').removeClass('prevent-events');
                },500);</span></span></span></span>


二、禁止横(竖)屏幕


方式一、phonegap端修改:


config.xml文件中修改:

<span style="font-size:14px;"><span style="font-size:14px;"><preference name="orientation" <span style="color:#FF0000;">value="default"</span>/></span></span>


value="portrait" 禁止横屏;value="landscape" 禁止竖屏;value="default" 无禁止,自由旋转。


方式二、在AndroidManifest.xml的activity(需要禁止转向的activity)配置中加入 android:screenOrientation=”landscape”属性即可(landscape是横向,portrait是纵向)。例如:

<span style="font-size:14px;"><span style="font-size:14px;"><application android:persistent="true"
    android:label="@string/home_title"
    android:icon="@drawable/ic_launcher_home">

<activity android:name="Home"
    android:theme="@style/Theme"
    android:launchMode="singleInstance"
    android:stateNotNeeded="true"
    android:screenOrientation="portrait">
        <intent-filter>
            <action android:name="android.intent.action.MAIN"/>
            <category android:name="android.intent.category.HOME"/>
            <category android:name="android.intent.category.DEFAULT"/>
        </intent-filter>
</activity></span></span>

另外,android中每次屏幕方向切换时都会重启Activity,所以应该在Activity销毁前保存当前活动的状态,在Activity 再次Create的时候载入配置,那样,进行中的游戏就不会自动重启了!

要避免在转屏时重启activity,可以通过在androidmanifest.xml文件中重新定义方向(给每个activity加上 android:configChanges=“keyboardHidden|orientation”属性),并根据Activity的重写 onConfigurationChanged(Configuration newConfig)方法来控制,这样在转屏时就不会重启activity了,而是会去调用 onConfigurationChanged(Configuration newConfig)这个钩子方法。例如:

<span style="font-size:14px;"><span style="font-size:14px;">if(newConfig.orientation==Configuration.ORIENTATION_LANDSCAPE){
    //横向
    setContentView(R.layout.file_list_landscape);
}else{
    //竖向
    setContentView(R.layout.file_list);
}</span></span>

在模拟器中,要使程序转屏可以使用快捷键F12或Ctrl+F11来切换。当然在用命令行启动模拟器时可以直接使用参数emulator.exe -skin HVGA-L来启动横屏的程序。

 

三、自动拨号(android)

<span style="font-size:14px;"><span style="font-size:14px;">电话:<a href="<span style="color:#ff0000;">tel:10086</span>">中国移动</a></span></span>

同时要在config.xml中加上:

<span style="font-size:14px;"><access origin="tel:*" launch-external="yes"/></span>


类似的权限还有:

<span style="font-size:14px;"><access origin="geo:*" launch-external="yes"/>
<access origin="mailto:*" launch-external="yes"/>
<access origin="sms:*" launch-external="yes"/>
<access origin="market:*" launch-external="yes"/></span>


具体可以参考:http://rickluna.com/wp/2012/02/making-a-phone-call-from-within-phonegap-in-android-and-ios/


四、使用系统浏览器打开链接

  1. navigator.app.loadUrl(url,{ openExternal:true });  
  2. The "navigator.app" object is only available on Android. Luckily in the soon to be released 2.3.0 version of PhoneGap you will be able to do:






基于可靠性评估序贯蒙特卡洛模拟法的配电网可靠性评估研究(Matlab代码实现)内容概要:本文围绕“基于可靠性评估序贯蒙特卡洛模拟法的配电网可靠性评估研究”,介绍了利用Matlab代码实现配电网可靠性的仿真分析方法。重点采用序贯蒙特卡洛模拟法对配电网进行长时间段的状态抽样与统计,通过模拟系统元件的故障与修复过程,评估配电网的关键可靠性指标,如系统停电频率、停电持续时间、负荷点可靠性等。该方法能够有效处理复杂网络结构与设备时序特性,提升评估精度,适用于含分布式电源、电动汽车等新型负荷接入的现代配电网。文中提供了完整的Matlab实现代码与案例分析,便于复现和扩展应用。; 适合人群:具备电力系统基础知识和Matlab编程能力的高校研究生、科研人员及电力行业技术人员,尤其适合从事配电网规划、运行与可靠性分析相关工作的人员; 使用场景及目标:①掌握序贯蒙特卡洛模拟法在电力系统可靠性评估中的基本原理与实现流程;②学习如何通过Matlab构建配电网仿真模型并进行状态转移模拟;③应用于含新能源接入的复杂配电网可靠性定量评估与优化设计; 阅读建议:建议结合文中提供的Matlab代码逐段调试运行,理解状态抽样、故障判断、修复逻辑及指标统计的具体实现方式,同时可扩展至不同网络结构或加入更多不确定性因素进行深化研究。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值