I use UIWebView in my app and it all worked fine in Xcode4,5,6 simulator. but not for Xcode 7 simulator, I don't know why, there is no warning or error in simulator, and the screen is just showing blank page. Please help me. Thanks.
#import "IndexViewController.h"
@interface IndexViewController ()
@end
@implementation IndexViewController
- (void)viewDidLoad
{
[super viewDidLoad];
NSString *urlString = nil;
NSString *languageCode = [[NSLocale preferredLanguages] objectAtIndex:0];
if ([languageCode isEqualToString:@"zh-Hans"]) {
urlString = @"http://www.originoftime.net/index-cn";
}else if ([languageCode isEqualToString:@"zh-Hant"]) {
urlString = @"http://www.originoftime.net/index-cn";
}else{
urlString = @"http://www.originoftime.net/index-en";
}
NSURL *url = [NSURL URLWithString:[urlString stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding]];
NSURLRequest *urlrequest = [NSURLRequest requestWithURL:url];
[_Index loadRequest:urlrequest];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
Xcode 7 with iOS9 now force you to not use HTTP call, but HTTPS ones.
this is a security point enhanced in AppTransportSecurity.
Try this:
Reload your app.
I advice you that if Apple want to block HTTP (unsecured) calls is for a good reason. http://www.originoftime.net/index-cn has a HTTPS one but the server certificate seems to be self-signed.
Let me know if this workaround work for you
Cheers from france
Do you implement the web view delegate methods? In particular:
- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error
If a load fails, that will tell you what the issue is.
It could well be the error related to the new security model which is being enforced for network access. You can override this new behavior by adding the following into your Info.plist file. Just edit the XML and paste this in:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key><true/>
</dict>
The changes are summarized here: https://developer.apple.com/library/prerelease/ios/technotes/App-Transport-Security-Technote/index.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With