I want to increase the height of the UIWebView while the user zooms in (for example, the default email application on the iPhone). So, I tried the code below to find scrollview in webview and add UIScrollViewDelegate to use scrollViewDidZoom to scale out to increase the height of the scrollViewDidZoom by this method.
// MessageAppDelegate.h @interface MessageAppDelegate : NSObject <UIApplicationDelegate,UIWebViewDelegate,UIScrollViewDelegate> { UIWebView *webview; UIScrollView *scrollview; } //MessageAppDelegate.m - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{ [self.window makeKeyAndVisible]; webview = [[UIWebView alloc] initWithFrame:CGRectMake(0, 150, 320, 100)]; webview.delegate = self; webview.scalesPageToFit = YES; webview.userInteractionEnabled = YES; [webview loadHTMLString:@"<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, maximum-scale=6.0 user-scalable=yes\">test test" baseURL:nil]; [self.window addSubview:webview]; // Find scrollview in webview for (UIView *view in webview.subviews) { if ([view isKindOfClass:[UIScrollView class]]) { // Get UIScrollView object scrollview = (UIScrollView *) view; scrollview.delegate = self; } } return YES; } - (void)scrollViewDidEndZooming:(UIScrollView *)scrollView withView:(UIView *)view atScale:(float)scale{ NSLog(@"scale %f",scale); } - (void)scrollViewDidZoom:(UIScrollView *)scrollView{ NSLog(@"scrollViewDidZoom %f",scrollview.zoomScale); }
The problem is that I cannot zoom in / out in the scrollViewDisEndZooming but NSLog on scrollViewDisEndZooming showed
scale 1.0
when i finished scaling and scrollViewDidZoom didn't show anything. I want to determine the zoom scale of a webview to calculate its height on scrollViewDidZoom .
What have I done wrong? Please, help.
Thanks in advance.
Dolly source share