UIViewController *webViewController = [[[UIViewController alloc] init] autorelease];
UIWebView *uiWebView = [[[UIWebView alloc] initWithFrame: CGRectMake(0,0,320,480)] autorelease];
NSString *urlst=[[NSString alloc]initWithString:[catWebArray objectAtIndex:indexPath.row]];
[uiWebView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:urlst]]];
uiWebView.scalesPageToFit=YES;
[webViewController.view addSubview: uiWebView];
[self.navigationController pushViewController:webViewController animated:YES];
where array contains adress like http://www.google.com,www.yahoo.com.
as these are added by users http:// may be added or not. so how i can load it in uiwebview?
You didn’t specify what the user interface for your application looks like, or how the user actually enters in the URL, so I am just going to assume it’s a text field that looks like what Mobile Safari uses.
You can write a method that you call before doing your
requestWithURLcall, and if you don’t see a scheme pre-pended to the user’s inputted URL, you can then return one with ahttp://added onto it.E.G.
(this snippet of code above isn’t perfect but is meant to be something to get you started… the rangeOfString call doesn’t take into consideration something fat fingered users may potentially do, like putting a scheme at the end of a string… e.g.
"www.google.comhttp://")