我有一张信用卡表格,在iPhone上的Safari中查看时显示iOS8功能“扫描信用卡”。它很棒。用户可以使用iPhone上的相机扫描信用卡。我通过在输入字段上添加HTML5自动完成标记(cc-number,cc-exp-year,cc-exp-month)来完成此操作。然后,Safari会自动识别并激活扫描功能。但是我想在我的iOS应用程序中的Web视图中显示它。表单显示,但扫描功能没有。这可能吗?
这是与Is the Scan Credit Card option available on the WebView?
相同的问题我想在那里发表评论,但我是新用户,所以我不能?
答案 0 :(得分:3)
我一直在尝试,并且无法在UIWebView或WKWebView中完成这项工作。源html文件是从启用https的服务器提供的。从Safari访问URL时显示“自动填充信用卡”,但嵌入iOS时不显示。遗憾的是,我认为UIWebView或WKWebView不支持此功能。
<!DOCTYPE html>
<html>
<head>
<title>Scan credit card using iOS</title>
<style type="text/css">
/*<![CDATA[*/
input {height:1.5em;width:95%}
input[type="text"] {font-size: 2.5em}
body {background-color:lightgray;font-size: 3em;font-family: sans-serif;}
#purchase {font-size: 2em;font-weight: bold;height:1.2em}
/*]]>*/
</style>
</head>
<body>
<form action="https://yoursite.com/credit-card-purchase" method="post">
<label for="nameoncard">Name on Card</label>
<input autocomplete="cc-name" id="nameoncard" name="nameoncard" type="text">
<label for="ccnumber">Credit Card Number</label>
<input autocomplete="cc-number" id="ccnumber" name="ccnumber" type="text">
<label for="cc-exp-month">Expiration Month</label>
<input autocomplete="cc-exp-month" id="cc-exp-month" name="cc-exp-month" type="text">
<label for="cc-exp-year">Expiration Year</label>
<input autocomplete="cc-exp-year" id="cc-exp-year" name="cc-exp-year" type="text">
<label for="cvv2">CVV</label> <input autocomplete="cc-csc" id="cvv2" name="cvv2" type="text">
<input name="submit" type="submit" value="Submit">
</form>
</body>
</html>
- (void)viewDidLoad {
[super viewDidLoad];
NSURL *nsurl = [NSURL URLWithString:@"https://www.myhttpsserver.co.uk/test.html"];
BOOL showWKWebView = YES;
if (showWKWebView) {
//WKWebView version
WKWebViewConfiguration *theConfiguration = [[WKWebViewConfiguration alloc] init];
WKWebView *webView = [[WKWebView alloc] initWithFrame:self.view.frame configuration:theConfiguration];
NSURLRequest *nsrequest=[NSURLRequest requestWithURL:nsurl];
[webView loadRequest:nsrequest];
[self.view addSubview:webView];
} else {
//UIWebView version
UIWebView *webView = [[UIWebView alloc] initWithFrame: self.view.frame];
webView.delegate = self;
NSURLRequest *request = [[NSURLRequest alloc] initWithURL:nsurl cachePolicy: NSURLRequestUseProtocolCachePolicy timeoutInterval: 5.0];
[webView loadRequest:request];
[self.view addSubview:webView];
}
}