I want to fit large image into UIwebview with keeping image ratio same as image view.
How can i do it.?
My code as follows to fit image in Uiwebview.
if image is large then display is not good.
CGFloat screenWidth = self.view.frame.size.width;
CGFloat screenHeight = self.view.frame.size.height;
NSString *htmlString = [NSString stringWithFormat:@"%@", @"<html><head><meta name='viewport' content='user-scalable=yes,width=device-width'></head><body bgcolor='000000'><img src='%@' width='%f' height='%f' style='max-width:200% max-height:200%'></body></html>"];
imageHTML = [[NSString alloc] initWithFormat:htmlString, fileUrl, screenWidth, screenHeight];
[Webview loadHTMLString:imageHTML baseURL:nil];
[imageHTML release];
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…