通过将 webView 存储在 Array/plist 中进行选项卡式浏览?

发布于 2024-07-29 22:42:33 字数 1518 浏览 10 评论 0原文

我想构建一个选项卡浏览器,到目前为止我已经实现了除选项卡式浏览之外的所有内容(书签、设置...)。

到目前为止我所知道的是,我应该将我的 webView 存储在数组或字典中,然后检索它。 但它似乎不起作用。

这是我迄今为止尝试过的各种变体:

[mainDrowser.webView removeFromSuperview]; 
mainDrowser.webView = [mainDrowser.arrayForTest objectAtIndex:anIndex];
[self.view addSubview:webView];

视图确实出现了,但它没有保存的 webView 的内容,而是我刚刚删除的 webView 的内容。

有人对如何做到这一点有建议吗?

我也尝试过:

-(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]];

}

在另一个类中:

DrowserAppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
    DrowserViewController *mainDrowser = [appDelegate drowserViewController];
    NSString *urlStringForWebView = [mainDrowser.tabDictionary valueForKey:cellTitle];

    [mainDrowser showWebViewFromDictionaryAtKey:urlStringForWebView];

这也不起作用。 同样的问题

我也尝试通过不删除和添加它来更改 webView。 如果我将 webView 存储在数组中,是否有可能不会存储内容,而只存储视图的属性?

有谁知道它是否可以与私有框架一起使用? 这个应用程序只是为了好玩,并不适用于 AppStore

提前感谢您的帮助!

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!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

月朦胧 2024-08-05 22:42:33

没关系。 我犯了一个愚蠢的菜鸟错误(我对开发非常陌生,只有 3 周的经验:D)

我必须为每个选项卡创建一个新的 UIWebView 实例。

对于这个错误,我们深表歉意。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文