我有一个 html 页面,点击提交按钮我需要调用支付网关 URL。
我正在使用 NSMutableURLRequest
并传递发布数据,我正在使用
调用 URL
请找到以下代码:
NSDictionary *parameters = [NSDictionary dictionaryWithObjects:[NSArray arrayWithObjects:currency_code,apikey,merchant_id,checksum_method,authorize_user,ip_address,hash,NB, nil] forKeys:[NSArray arrayWithObjects:@"currency_code",@"apikey",@"merchant_id",@"checksum_method",@"authorize_user",@"ip_address",@"checksum",@"cardType", nil]];
__block NSString *post = @"";
[parameters enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) {
if ([post isEqualToString:@""]) {
post = [NSString stringWithFormat:@"%@=%@",key,obj];
} else {
post = [NSString stringWithFormat:@"%@&%@=%@",post,key,obj];
}
}];
NSData *postData = [post dataUsingEncoding:NSUTF8StringEncoding allowLossyConversion:YES];
NSString *postLength = [NSString stringWithFormat:@"%ld",[postData length]];
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];
[request setURL:[NSURL URLWithString:@"http://pay.sandbox.shmart.in/pay_merchant/js"]];
[request setHTTPMethod:@"POST"];
[request setValue:postLength forHTTPHeaderField:@"Content-Length"];
[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
[request setHTTPBody:postData];
[webview loadRequest:request];
webViewDidFinishLoad
也被调用,但它显示的是空白屏幕。
关于问题所在的任何想法。
最佳答案
传输安全已阻止明文 HTTP (http://) 资源加载,因为它不安全,您需要添加 您必须将
NSAllowsArbitraryLoadskey 设置为
YES under
NSAppTransportSecuritydictionary in your
.plist file`.,并尝试查看此 link
关于ios - 即使在加载 url 后,UIWebview 仍显示空白屏幕,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38604257/