iphone - How to detect zoom scale of UIWebView -


I want to increase the height of UIWebView , while user zoom in (like the default mail app in the iPhone ). So, to find the scrollview in the webview and to use UIScrollViewDelegate to add the scrollViewDidZoom zoom scale to add the height of the webview on this method Have tried the code below.

  // MessageAppDelegate.h @interface MessageAppDelegate: NSObject & LT; UIApplicationDelegate, UIWebViewDelegate, UIScrollViewDelegate & gt; {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 Load HTML String: @ "Meta Name = \" Viewport \ "content = \" width = device-width, initial-scale = 1.0, max-scale = 6.0 user-scalable = yes \ "test test" Basic URL: zero ]; [Self. Window Adsview: Webview]; Find the scrollview in web view for // (see in UIView * webview.subviews {if ([view isKindOfClass: [UIScrollView class]]) // // UIScrollView object scrollview = (UIScrollView *) view; Scrollview.delegate = self; }} Yes return; } - Scrollview (UIView *) with Scrollview and Zooming: (UIScrollView *) Scale: (float) scale {nslog (@ "scale% f", scale); } - (Zero) ScrollViewz Zoom: (UIScrollView *) ScrollView {NSLog (@ "scrollwidid zoom% F", scrollview zoomscale); }   

The problem is that I can not zoom in / out on the webview, but the NSLog scrollViewDisEndZooming method shown

scale 1.0

When I ended zooming and the scrollViewDidZoom method did not show anything. I want to search the webview's zoom scale to calculate my height at scrollViewDidZoom .

What have I done? help please.

Thanks in advance.

I've done well for your code, follow the following amendments: < P> You can get scrollview points only, then you can get the ScrollView content size.width, which you can change while zooming in, but scrollview.zoomScale always remains. To use contensize.width to calculate scale

  @interface dictViewController:. UIViewController & LT; UIWebViewDelegate, UITextFieldDelegate, UIGestureRecognizerDelegate, UIScrollViewDelegate & gt; {UIScrollView * scrollview; ...................... //scrollview.delegate = self; (See in UIView * webViewM.subviews) {if ([view isKindOfClass: [UIScrollView class]]) // // View UIScrollView object scrollwaves = (UIScrollView *); //scrollview.delegate = self; }} / * - (zero) scrollViewDidEndZooming: (UIScrollView *) scrollview withView: (UIView *) view atScale: scale ({// NSLog (@ "scale zooming% f", scale); } - (Zero) ScrollViewz Zoom: (UIScrollView *) ScrollView {// NSLog (@ "scrollwidid zoom% F", scrollview.zuscale); } * / - (zero) Swipete Action: (ID) kept in mind {nslog (@ "wid =% f", scrollview.contentSize.width); NSLog (@ "zoomscale =% F", scrollview zoomscale); }    

Comments

Popular posts from this blog

qt - switch/case statement in C++ with a QString type -

python - sqlite3.OperationalError: near "REFERENCES": syntax error - foreign key creating -

Python's equivalent for Ruby's define_method? -