0
如果我想稍后保留一个UIWebView以“重用”,是否有可能?例如,假设某个特定网站上的UIWebView对您的应用程序非常重要,但不是唯一的。也许该网站需要一段时间来加载。当用户从UIWebView导航离开时,我想保留对UIWebView及其内容的引用,所以如果用户决定重新打开webview,那么它就是他或她离开它的地方。保留UIWebView,稍后再显示它?
我试过这个,它似乎不适合我。在我的情况下,在iPad上,有一个部分屏幕UIWebView,我保持强烈的引用,如果用户需要,我呈现一个全屏模态视图,并将该UIWebView引用插入一个合成的UIWebView属性中视图控制器。当模式视图全屏显示时,背景只是白色,而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];