Reputation: 39
I am building a web browser that creates a new UIWebview when I add another tab.Each new view is given a tag upon creation which allows me to call a specific view. When I call the subview to front it does not respond to a load request. This is how I am bringing the subview to the front
-(void) selectionMade:(id)sender
{
//find view with same tag num as button pushed
for (UIView *view in self.webView.subviews)
{
if (view.tag == [sender tag])
{
[self.webView bringSubviewToFront:view];
}
}
}
Here is the code for responding to the text field that I enter the address into.
- (void)textFieldDidEndEditing:(UITextField *)textField
{
NSString *text = [textField.text lowercaseString];
if (![text hasPrefix:@"http://"] && ![text hasPrefix:@"https://"])
{
text = [NSString stringWithFormat:@"http://%@", text];
}
self.title = text;
url = [NSURL URLWithString:text];
NSURLRequest *request = [NSURLRequest requestWithURL:url cachePolicy:NSURLCacheStorageAllowedInMemoryOnly timeoutInterval:10.];
[self.webView loadRequest:request];
}
Upvotes: 0
Views: 427
Reputation: 57040
You should not be adding other webviews as subviews of your webview. This is an incorrect design. Practically, what happens is you call loadRequest:
on the main webview, but bring one of its subviews to front, which hides the main webview's content.
Depending on the experience you want to provide, you have several options.
Upvotes: 1