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