tabbed browsing by storing webView in an Array/plist?
Question
I want to build a tab-Browser and so far I've implemented everything (Bookmarks, settings...) except tabbed browsing.
What I know so far is that I should store my webView
in an array or a dictionary and then retrieve it. but it doesn't seem to work.
This is what I've tried so far in various variations:
[mainDrowser.webView removeFromSuperview];
mainDrowser.webView = [mainDrowser.arrayForTest objectAtIndex:anIndex];
[self.view addSubview:webView];
The view does appear, but it doesn't have the content of the saved webView but the content of the one I just removed.
Does anyone have a suggestion on how to do this?
Also something I tried:
-(IBAction) saveAsTab:(id)sender {
[tabDictionary setValue:addressField.text forKey:[webView stringByEvaluatingJavaScriptFromString:@"document.title"]];
NSLog(@"tabDictionary: %@", tabDictionary);
[tabData setValue:webView forKey: addressField.text];
NSLog(@"tabData: %@", tabData);
-(void) showWebViewFromDictionaryAtKey:(NSString *)urlForWebView {
[webView removeFromSuperview];
[self.view addSubview:(UIWebView *)[tabData valueForKey:urlForWebView]];
}
In another class:
DrowserAppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
DrowserViewController *mainDrowser = [appDelegate drowserViewController];
NSString *urlStringForWebView = [mainDrowser.tabDictionary valueForKey:cellTitle];
[mainDrowser showWebViewFromDictionaryAtKey:urlStringForWebView];
This doesn't work either. Same problem
I also tried to change the webView by not removing and adding it. Is it possible that if I store a webView in an array the content isn't stored but only the properties of the view?
Does anyone have an idea if it might work with a private framework? this app is just for fun and not for the AppStore
thanks in advance for any help!
Solution
nevermind. I made a stupid noobish mistake (I'm very new to developing, only 3 weeks of experience :D)
I have to create a new instance of UIWebView for each tab.
sorry for this mistake.