gpt4 book ai didi

ios - 保留UIWebView,以后再显示?

转载 作者:行者123 更新时间:2023-11-28 23:11:07 24 4
gpt4 key购买 nike

如果我想保留一个 UIWebView 以供以后“重用”,是否可能?例如,假设特定站点上的 UIWebView 对您的应用很重要,但不是其中唯一的东西。也许网站需要一段时间才能加载。当用户离开 UIWebView 时,我想保留对 UIWebView 及其内容的引用,因此如果用户决定重新打开 webview,它就是他或她离开的地方。

我已经试过了,但似乎对我不起作用。在我的情况下,在 iPad 上,有一个部分屏幕 UIWebView,我一直强烈引用它,如果用户需要,我将呈现一个全屏模态视图,并将该 UIWebView 引用插入到合成的 UIWebView 属性中 View Controller 。当模态视图全屏显示时,背景只是白色,webview 不显示任何内容,即使我为其保留指针的现有 webview 已经有事件。

@interface FullScreenWebView : UIViewController
@property (nonatomic,strong) IBOutlet UIWebView *theWebView;

@interface HalfScreenWebView : UIViewController
@property (nonatomic,strong) IBOutlet UIWebView *aWebView;

//in some other class, pretend halfscreenWebView is an object representing HalfScreenWebView
UIWebView *existingWebView = halfscreenWebView.aWebView;
FullScreenWebView *full = [[FullScrenWebView alloc] initWithNibName:@"FullScreenWebView" bundle:nil];
full.modalPresentationStyle = UIModalPresentationStyleFullScreen;
full.theWebView = existingWebView;
[self presentModalViewController:full animated:YES];

最佳答案

您可以使用 NSCoding在使用之间归档和取消归档 UIWebView,因为它符合 NSCoding 协议(protocol)。

关于ios - 保留UIWebView,以后再显示?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8236450/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com