- objective-c - iOS 5 : Can you override UIAppearance customisations in specific classes?
- iphone - 如何将 CGFontRef 转换为 UIFont?
- ios - 以编程方式关闭标记的信息窗口 google maps iOS
- ios - Xcode 5 - 尝试验证存档时出现 "No application records were found"
我在 iPad 上使用 iOS 11 上的 Phonegap 时遇到问题。如果单击选择,它会在弹出窗口中显示选项。选择一个后,弹出窗口短暂消失,选择中的选项发生变化,然后弹出窗口重新出现。 Xcode 控制台中出现以下消息:
[Warning] Application tried to represent an active popover presentation: <UIPopoverPresentationController: 0x100c3e450>
编辑:弹出窗口重新出现后,点击它没有任何反应。
如何让选择在选择一个选项后不重新显示弹出窗口?
这是使用最新的 Phonegap 7.0.1。
这只是一个普通的 html 选择:
<!doctype html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1 maximum-scale=1, user-scalable=no" />
<meta http-equiv="Content-Security-Policy" content="default-src * 'unsafe-inline' 'unsafe-eval'">
<script type="text/javascript" src="cordova.js"></script>
</head>
<body>
<select>
<option value="1">Option 1</option>
<option value="2">Option 2</option>
<option value="3">Option 3</option>
</select>
</body>
</html>
您可以在此处下载示例项目:
https://github.com/tomkincaid/selecttest
我通过在 Xcode 中直接打开 platforms/ios/SelectTest.xcodeproj 来运行它。
编辑:有两次选择,行为更加奇怪。
<select id="select1">
<option value="1">One</option>
<option value="2">Two</option>
<option value="3">Three</option>
</select>
<select id="select2">
<option value="4">Four</option>
<option value="5">Five</option>
<option value="6">Six</option>
</select>
点击select1,弹出select1选项。
选择一个选项,弹出窗口短暂消失然后重新出现。
点击主体使弹出窗口消失。
点击选择2。出现 select1 弹出窗口。
单击正文使弹出窗口消失。弹出窗口短暂消失,然后重新显示为空。
点击主体使弹出窗口消失。
再次点击选择2。现在它显示正确的弹出窗口。
最佳答案
这似乎是 iOS 11 上 UIWebVIew 的一个问题,适用于 iPad 上的所有应用程序,而不仅仅是 Phonegap/Cordova。由于 UIWebVIew 已针对 WKWebView 贬值,因此 Apple 不太可能修复它。在 Phonegap/Cordova 使用 WKWebView 之前,我一起破解了这个修复程序。基本上,它将一个 div 放在选择上,然后从自定义插件打开一个选择器。
index.html
<!doctype html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1 maximum-scale=1, user-scalable=no" />
<meta http-equiv="Content-Security-Policy" content="default-src * 'unsafe-inline' 'unsafe-eval'">
<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript" src="PhonegapUtility.js"></script>
<script type="text/javascript">
function onBodyLoad() {
document.addEventListener("deviceready", onDeviceReady, false);
}
function onDeviceReady() {
addSelectButton('#selecta');
addSelectButton('#selectb');
}
function addSelectButton(selectID) {
var u = new PhonegapUtility();
u.isIpad(function(resp){
if (resp == 1) {
var buttonID = selectID+"Button";
if($(buttonID).length == 0) {
$("body").append("<div id='"+buttonID.replace("#","")+"' onclick='showPicker(\""+selectID+"\");'></div>");
}
$(buttonID).css("position","absolute");
$(buttonID).css("left",$(selectID).offset().left+"px");
$(buttonID).css("top",""+$(selectID).offset().top+"px");
$(buttonID).css("width",$(selectID).width()+"px");
$(buttonID).css("height",$(selectID).height()+"px");
// need to adjust this for margin and padding
}
});
}
function showPicker(selectID) {
var optionArray = [];
$(selectID).find('option').each(function(index,element){
optionArray.push(element.text);
});
var u = new PhonegapUtility();
u.showPicker(optionArray.join("|||"),$(selectID).prop('selectedIndex'),function(resp){
$(selectID+" option")[resp].selected = true;
});
}
</script>
</head>
<body onload="onBodyLoad();">
<select id="selecta">
<option value="1">Option 1</option>
<option value="2">Option 2</option>
<option value="3">Option 3</option>
</select>
<select id="selectb">
<option value="4">Option 4</option>
<option value="5">Option 5</option>
<option value="6">Option 6</option>
</select>
</body>
</html>
PhonegapUtility.h
#import <Cordova/CDV.h>
@interface PhonegapUtility : CDVPlugin <UIPickerViewDelegate,UIPickerViewDataSource>
@property (strong, nonatomic) NSString *callbackId;
@property (strong, nonatomic) UIPickerView *pickerView;
@property (strong, nonatomic) UIView *pickerWrappertView;
@property (strong, nonatomic) NSArray *pickerData;
- (void) isIpad:(CDVInvokedUrlCommand*)command;
- (void) showPicker:(CDVInvokedUrlCommand*)command;
- (void) pickerDone;
@end
PhonegapUtility.m
#import "PhonegapUtility.h"
#import "AppDelegate.h"
@implementation TomPhonegapUtility
@synthesize callbackId,pickerData,pickerView,pickerWrappertView;
- (void) isIpad:(CDVInvokedUrlCommand*)command {
int iPad = 0;
if ( UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad ) iPad = 1;
CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsInt:iPad];
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
}
- (void) showPicker:(CDVInvokedUrlCommand*)command {
callbackId = [[NSString alloc] initWithString: command.callbackId];
AppDelegate *appDelegate = (AppDelegate *) [[UIApplication sharedApplication] delegate];
UIViewController *rootViewController = appDelegate.window.rootViewController;
pickerData = [[command.arguments objectAtIndex:0] componentsSeparatedByString:@"|||"];
float viewWidth = rootViewController.view.bounds.size.width; //[UIScreen mainScreen].bounds.size.width;
float viewHeight = rootViewController.view.bounds.size.height; //[UIScreen mainScreen].bounds.size.height;
UIToolbar *toolBar= [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, viewWidth, 44)];
[toolBar setBarStyle:UIBarStyleDefault];
UIBarButtonItem *flex = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:nil];
UIBarButtonItem *barButtonDone = [[UIBarButtonItem alloc] initWithTitle:@"Done"
style:UIBarButtonItemStylePlain
target:self
action:@selector(pickerDone)];
toolBar.items = @[flex, barButtonDone];
pickerView = [[UIPickerView alloc] init];
[pickerView setDataSource: self];
[pickerView setDelegate: self];
[pickerView setFrame: CGRectMake(0, toolBar.frame.size.height, viewWidth, 180.0f)];
pickerView.showsSelectionIndicator = YES;
[pickerView selectRow:[[command.arguments objectAtIndex:1] intValue] inComponent:0 animated:NO];
pickerWrappertView = [[UIView alloc] initWithFrame:CGRectMake(0, viewHeight-toolBar.frame.size.height-pickerView.frame.size.height, viewWidth, toolBar.frame.size.height + pickerView.frame.size.height)];
pickerWrappertView.backgroundColor = [UIColor whiteColor];
[pickerWrappertView addSubview:pickerView];
[pickerWrappertView addSubview:toolBar];
[rootViewController.view addSubview:pickerWrappertView];
}
- (void) pickerDone {
int selectedIndex = (int) [pickerView selectedRowInComponent:0];
CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsInt:selectedIndex];
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
[pickerWrappertView removeFromSuperview];
}
-(NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView{
return 1;
}
-(NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component{
return [pickerData count];
}
-(NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component{
return [pickerData objectAtIndex:row];
}
-(void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component{
}
关于ios - iOS 11 上的 Phonegap/Cordova 选择选项后再次显示弹出窗口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46370739/
我的Angular-Component位于一个flexbox(id =“log”)中。可以显示或隐藏flexbox。 我的组件内部有一个可滚动区域,用于显示日志消息。 (id =“message-li
我真的很困惑 有一个 phpinfo() 输出: MySQL 支持 启用 客户端 API 版本 5.5.40 MYSQL_MODULE_TYPE 外部 phpMyAdmin 显示: 服务器类型:Mar
我正在研究这个 fiddle : http://jsfiddle.net/cED6c/7/我想让按钮文本在单击时发生变化,我尝试使用以下代码: 但是,它不起作用。我应该如何实现这个?任何帮助都会很棒
我应该在“dogs_cats”中保存表“dogs”和“cats”各自的ID,当看到数据时显示狗和猫的名字。 我有这三个表: CREATE TABLE IF NOT EXISTS cats ( id
我有一个字符串返回到我的 View 之一,如下所示: $text = 'Lorem ipsum dolor ' 我正在尝试用 Blade 显示它: {{$text}} 但是,输出是原始字符串而不是渲染
我无法让我的链接(由图像表示,位于页面左侧)真正有效地显示一个 div(包含一个句子,位于中间)/单击链接时隐藏。 这是我的代码: Practice
关闭。这个问题需要多问focused 。目前不接受答案。 想要改进此问题吗?更新问题,使其仅关注一个问题 editing this post . 已关闭 4 年前。 Improve this ques
最初我使用 Listview 来显示 oracle 结果,但是最近我不得不切换到 datagridview 来处理比 Listview 允许的更多的结果。然而,自从切换到数据网格后,我得到的结果越来越
我一直在尝试插入一个 Unicode 字符 ∇ 或 ▽,所以它显示在 Apache FOP 生成的 PDF 中。 这是我到目前为止所做的: 根据这个基本帮助 Apache XSL-FO Input,您
我正在使用 node v0.12.7 编写一个 nodeJS 应用程序。 我正在使用 pm2 v0.14.7 运行我的 nodejs 应用程序。 我的应用程序似乎有内存泄漏,因为它从我启动时的大约 1
好的,所以我有一些 jQuery 代码,如果从下拉菜单中选择了带有前缀 Blue 的项目,它会显示一个输入框。 代码: $(function() { $('#text1').hide();
当我试图检查 Chrome 中的 html 元素时,它显示的是 LESS 文件,而 Firefox 显示的是 CSS 文件。 (我正在使用 Bootstrap 框架) 如何在 Chrome 中查看 c
我是 Microsoft Bot Framework 的新手,我正在通过 youtube 视频 https://youtu.be/ynG6Muox81o 学习它并在 Ubuntu 上使用 python
我正在尝试转换从 mssql 生成的文件到 utf-8。当我打开他的输出 mssql在 Windows Server 2003 中使用 notepad++ 将文件识别为 UCS-2LE我使用 file
很难说出这里问的是什么。这个问题是含糊的、模糊的、不完整的、过于宽泛的或修辞性的,无法以目前的形式得到合理的回答。如需帮助澄清此问题以便重新打开它,visit the help center 。 已关
我正在尝试执行单击以打开/关闭一个 div 的功能。 这是基本的,但是,点击只显示 div,当我点击“关闭”时,没有任何反应。 $(".inscricao-email").click(function
假设我有 2 张卡片,屏幕上一次显示一张。我有一个按钮可以用其他卡片替换当前卡片。现在假设卡 1 上有一些数据,卡 2 上有一些数据,我不想破坏它们每个上的数据,或者我不想再次重建它们中的任何一个。
我正在使用 Eloquent Javascript 学习 Javascript。 我在 Firefox 控制台上编写了以下代码,但它返回:“ReferenceError:show() 未定义”为什么?
我正在使用 Symfony2 开发一个 web 项目,我使用 Sonata Admin 作为管理面板,一切正常,但我想要做的是,在 Sonata Admin 的仪表板菜单上,我需要显示隐藏一些菜单取决
我试图显示一个div,具体取决于从下拉列表中选择的内容。例如,如果用户从列表中选择“现金”显示现金div或用户从列表中选择“检查”显示现金div 我整理了样本,但样本不完整,需要接线 http://j
我是一名优秀的程序员,十分优秀!