我有一個UIWebView
顯示來自網絡的文本和圖像。如何從UIWebView全屏顯示圖像?
我想要這樣做,當我點擊UIWebView中的圖像時,我想在包括方向的全屏中顯示它。
所以我用以下代碼進行了測試。
- (BOOL)webView:(UIWebView*)webView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType {
if (navigationType == UIWebViewNavigationTypeLinkClicked) {
NSURL *URL = [request URL];
NSData *data = [[NSData alloc] initWithContentsOfURL:URL];
UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageWithData:data]];
GGFullscreenImageViewController *vc = [[GGFullscreenImageViewController alloc] init];
vc.liftedImageView = imageView;
[self presentViewController:vc animated:YES completion:nil];
return NO;
}
else
{
return YES;
}
}
它不起作用,並顯示錯誤,當我點擊圖像在UIWebView
。
2014-03-12 13:59:40.397 MMSP[1368:a0b] *** Terminating app due to uncaught exception 'CALayerInvalidGeometry', reason: 'CALayer bounds contains NaN: [0 0; nan nan]'
*** First throw call stack:
有沒有辦法像我上面說的那樣做?
我沒有設置imageView frame becz GGFullScreenImageViewController可以自動完成 –
您確定該url包含圖片數據嗎? – sage444