我在UIWebView中显示一个有下拉列表的网站页面。用户可以从下拉列表中选择值,但是当应用程序关闭并再次打开时,此下拉列表将停止工作,这意味着用户无法选择它。
奇怪的是,如果我们在该dropdwon上显示javascript的警告框,那么在点击警告框的ok按钮后一切正常(意味着dropdwon变得可点击),那么它可能是什么原因和解决方案呢?
答案 0 :(得分:1)
我有同样的问题所以我找到了解决它的工作 在您的网站中,在document.ready中放入以下javascript行,其中包含下拉列表
/**
* Create a simple mobile accordion.
*/
Drupal.cgl.mobaccordion = function() {
var mobaccordion = $('.mobaccordion');
mobaccordion.each(function() {
var mobaccordionTitle = $(this).find('.mobaccordion-title');
var mobaccordionBody = $(this).find('.mobaccordion-body');
var mobaccordionIcon = $(this).find('.mobaccordion-icon');
var mobaccordionId = '#' + $(this).attr('id');
var target = window.location.pathname + '#' + mobaccordionId;
if ( (Drupal.cgl.isMobile()) && (mobaccordionIcon.length == 0) && (mobaccordionTitle.length != 0 ) ){
// Don't close accordion when referred to title.
if(window.location.hash != mobaccordionId) {
mobaccordionBody.hide();
}
// Create icon to click.
$(this).prepend('<a href="' + target + '" class="mobaccordion-icon" title="Dit menu-onderdeel kunt u uitklappen"><span class="element-invisible">Ingeklapt, klik om uit te klappen</span></a>');
var mobaccordionIcon = $(this).find('.mobaccordion-icon');
// Events when title or icons are clicked or pressed.
$(mobaccordionIcon).add(mobaccordionTitle).on('click', function (e) {
e.preventDefault();
var parent = $(this).parents('.mobaccordion');
Drupal.cgl.mobaccordionToggle(parent);
});
//$('#mobaccordion-11').addClass('open');
}
else if (Drupal.cgl.isMobile() == false) {
//unset and remove everything when screen is not mobile.
$(this).find('.mobaccordion-body').show();
$(this).removeClass('open');
$(mobaccordionIcon).add(mobaccordionTitle).off('click');
$('.mobaccordion-icon').remove();
}
});
};
Drupal.cgl.mobaccordionToggle = function(mobaccordion) {
mobaccordion.find('.mobaccordion-body').slideToggle();
mobaccordion.toggleClass('open');
mobaccordion.find('.mobaccordion-icon').toggleClass('active');
mobaccordion.find('.mobaccordion-icon .element-invisible').remove();
if (mobaccordion.hasClass('open')){
mobaccordion.find('.mobaccordion-icon').append('<span class="element-invisible">Uitgeklapt, klik om in te klappen</span>');
}else{
mobaccordion.find('.mobaccordion-icon').append('<span class="element-invisible">Ingeklapt, klik om uit te klappen</span>');
}
};
在你的UIWebView控制器中放入以下代码
var appname = 'yourappName';
var actionName = 'displayAlert';
var url = appname + '://' + actionName;
document.location.href = url;
当您的页面加载并执行javascript行时上面的代码不会丢失任何viewcontroller但会触发dropddown再次工作