views:

48

answers:

3

I have been trying to load the url http://friscotxcoc.weblinkconnect.com/cwt/External/WCPages2/wcevents/eventsstartpage.aspx?oe=true&ce=true into a webview but it shows up an error 'Entity nbsp not found'. The link works properly over Safari (Machine as well as simulator) but doesnt load properly when loaded through a webview. Can someone point me as to how to do it?

#define kEventsCalenderLink  @"http://friscotxcoc.weblinkconnect.com/cwt/External/WCPages2/wcevents/eventsstartpage.aspx?oe=true&ce=true"    
NSURL *eventsURL  = [NSURL URLWithString:kEventsCalenderLink];
eventsWebView.delegate = self;
[eventsWebView loadRequest:[NSURLRequest requestWithURL:eventsURL]];
+1  A: 

Do this in the way

NSString *kEventsCalenderLink @"http://friscotxcoc.weblinkconnect.com/cwt/External/WCPages2/wcevents/eventsstartpage.aspx?oe=true&ce=true"

NSLog(@"%@",kEventsCalenderLink); eventsWebView.delegate = self; eventsWebView.userInteractionEnabled = true; [eventsWebView loadRequest:[[NSURLRequest alloc] initWithURL:[[NSURL alloc] initWithString:kEventsCalenderLink]]];

You have only defined the url which you haven't mentioned that its string type.

Hope it would help you,if so then please vote me up.

Thanks Sabby.

sabby
Tried. no change.
Nareshkumar
have you included the http://www. in the string ,if you don't include http:// and simply use www.abc.com,then it won't work.I tried it my self.
sabby
Oh sorry i didn't read properly you want to play in webview,yes its showing some error.I will try if find some sol. then let you know dear.
sabby
+2  A: 

The server is serving that page with the Content-Type of "application/xhtml+xml" to the Simulator version of Safari. Safari is interpreting the page as strict XML, which does not have an   entity.

Unfortunately, UIWebView manipulates its HTTP headers behind the scenes, and it's seemingly impossible to configure it to make a request that will cause your server to serve content as "text/html"

The one workaround I would suggest is to retrieve the content with an NSURLConnection, then feed it to your web view with the loadData:MIMEType:textEncodingName:baseURL: method, being sure to pass "text/html" as the MIME type.

This may also necessitate intercepting future requests via the webView:shouldStartLoadWithRequest:navigationType: delegate method (in order to cancel them and load them in the manner described above to prevent similar problems).

Or, if you have control of the server, you could configure it to serve HTML with the appropriate content type. Or convert the content to use proper XML entities.

warrenm
A: 

Here is the sample code which i implemented.Hope it would help you

  • (void)loadView { UIView *vew=[[UIView alloc]initWithFrame:[[UIScreen mainScreen]bounds]]; self.view=vew; //self.title=@"sanjay"; //self.navigationItem.title=@"afdsfasd"; self.view.backgroundColor=[UIColor redColor]; [vew release];

    UIButton *smsbtn=[UIButton buttonWithType:UIButtonTypeRoundedRect]; smsbtn.frame=CGRectMake(50, 280, 100, 50);

    [smsbtn setTitle:@"SMS APP" forState:UIControlStateNormal]; [smsbtn setTitleEdgeInsets:UIEdgeInsetsZero]; [smsbtn addTarget:self action:@selector(loadsms) forControlEvents:UIControlEventTouchUpInside]; [self.view addSubview:smsbtn]; }

-(void)loadsms { NSString *url = [NSString stringWithFormat:@"http://friscotxcoc.weblinkconnect.com/cwt/External/WCPages2/wcevents/eventsstartpage.aspx?oe=true&ce=true"]; [[UIApplication sharedApplication] openURL:[NSURL URLWithString: url]];

}

This code is working dude.Try this out.I have implemented this for you only.

sabby