ios - 即使在加载 url 后,UIWebview 仍显示空白屏幕

标签 ios objective-c uiwebview

我有一个 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 underNSAppTransportSecuritydictionary in your.plist file`.,并尝试查看此 link

关于ios - 即使在加载 url 后,UIWebview 仍显示空白屏幕,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38604257/

相关文章:

ios - 在 Obj-C 中使用 Swift 扩展

ios - 如何让 VoiceOver 将 UITableView 视为单个可访问性元素?

objective-c - Objective C 登录时记住数据

ios - 如何使用括号内的字符串

iphone - 在核心图形中绘制阴影很慢

javascript - xcode 5,我想删除 uiWebView 中的一个类

ios - 当我滚动到当前滚动位置的顶部时,如何重新加载 UITableView? (比如聊天应用)

php - 如何在 ios 上从 Web 服务器加载数据

javascript - 如何从 Javascript 调用 Objective-C 方法并将数据发送回 iOS 中的 Javascript?

ios - 估计 UIWebView 的高度