tags:

views:

42

answers:

2

I have a simple iPhone app which will display html content I have placed in the Documents directory, but once it is displayed, the links do not work.

The following code is called from the init method of my app delegate.

Can anyone suggest what I have missed please?

-(void) loadWebView:(NSString*) appDirectory {
     CGRect rect = CGRectMake(0, 0, 320, 480);
     webView = [[UIWebView alloc] initWithFrame:rect];//init and create the UIWebView
     [webView setBounds:rect];


     // NSString* webViewFile = [appDirectory stringByAppendingString:@"index.html"];
     // NSString* protocol=@"file://";
     // NSString* fullUrl=[protocol stringByAppendingString:webViewFile];
     fullUrl=@"http://www.google.com";
     NSLog(@"Attempting to open url (unencoded) %@", fullUrl);
     fullUrl = [fullUrl stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
     NSLog(@"Attempting to open url (encoded) %@", fullUrl);

     //Create a URL object.
     NSURL *url = [NSURL URLWithString:fullUrl];

     //URL Requst Object
     NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
     webView.delegate=self;
     [webView loadRequest:requestObj];
     window = [[UIWindow alloc] init];
     [window addSubview:webView];
     [window makeKeyAndVisible];
     window.hidden=NO;
} 
A: 

I don't think you should create your own UIWindow object. This object is already in your xib and it is probably "madeKeyAndVisible" already in the applicationDidFinishLoading method.

Try to remove all lines relating to window, and add the subview to self.view, like

[self.view addSubview:webView];
mvds
Thanks, I will give it a try, and report back. There is no nib/xib file though. All the displayable content is dynamic, so I removed it and was intending to set everything up dynamically.
Justin
good luck then. I think you're asking for a lot of trouble when stripping things to the bare bones without knowing how to hook things up *exactly*.
mvds
A: 

The answer turns out to be that there are two clipping functions: one for display and one for interaction.

I had set my bounds to the screen size, but not my frame.

Obvious? Not really.

Justin