UIWebView not loading in ios

477 views Asked by At
NSURL *url = [NSURL URLWithString: address];
NSString *body = [NSString stringWithFormat: @"%@", webViewString];
NSMutableURLRequest *request = [[NSMutableURLRequest alloc]initWithURL: url];
[request setHTTPMethod: @"POST"];
[request setHTTPBody: [body dataUsingEncoding: NSUTF8StringEncoding]];
[_paymentWebView loadRequest: request];

I load the UIWebView but I got this error in my application when I try to access the PayUMoney payment gateway via UIWebView in above code but it show this error and I am using AFNetworking in other API calls. Kindly help me to resolve this error.

objc[4933]: Class PLBuildVersion is implemented in both /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/PrivateFrameworks/AssetsLibraryServices.framework/AssetsLibraryServices (0x12487e998) and /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/PrivateFrameworks/PhotoLibraryServices.framework/PhotoLibraryServices (0x1246a3d38). One of the two will be used. Which one is undefined.**

2

There are 2 answers

4
Poles On

Just use

NSURL *url = [NSURL URLWithString: address];
NSString *body = [NSString stringWithFormat: @"%@", webViewString];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[_paymentWebView loadRequest: request];

You don't need to use setHTTPBody or setHTTPMethod.

0
Fahim Parkar On

The code you have is not how we should load url in webview.

The sweet and simple way is as below to load URL in UIWebView.

NSURL *websiteUrl = [NSURL URLWithString:@"http://www.google.com"];
NSURLRequest *urlRequest = [NSURLRequest requestWithURL:websiteUrl];
[myWebView loadRequest:urlRequest];