[英]iphone uiwebview programmatic zoom
I'm developing an app that saves html files locally on iPhone file system, then load them in UIWebView. 我正在开发一个将html文件本地保存在iPhone文件系统上的应用程序,然后将其加载到UIWebView中。 I want to be able to zoom or double tap programmatically on the UIWebView, I tried searching for javascript code, but I could only scroll.
我希望能够以编程方式在UIWebView上进行缩放或双击,我尝试搜索javascript代码,但只能滚动。
I also tried the webview transform, but didn't work out for me. 我也尝试了webview转换,但对我来说没有用。 I found this method
我发现这种方法
sendAction:to:from:forEvent:
http://developer.apple.com/iphone/library/documentation/UIKit/Reference/UIApplication_Class/Reference/Reference.html#jumpTo_26 http://developer.apple.com/iphone/library/documentation/UIKit/Reference/UIApplication_Class/Reference/Reference.html#jumpTo_26
in the UIApplication class, that can send actions to controls. 在UIApplication类中,可以将操作发送到控件。
Does anybody know how to send the double tap action programmatically to a UIWebView on a certain x,y? 有人知道如何以编程方式将双击动作发送到某个x,y上的UIWebView吗?
get the UIWebview's subview which is a UIScrollview 获取UIWebview的子视图,即UIScrollview
UIScrollView *sview = [[webview subviews] objectAtIndex:0];
Then use zoom methods on that. 然后在其上使用缩放方法。
这是我能找到的唯一方法:(如果您愿意,请指定您自己的尺寸,我在输入表单字段后尝试缩小)
UIScrollView *sv = [[webViewView subviews] objectAtIndex:0]; [sv zoomToRect:CGRectMake(0, 0, sv.contentSize.width, sv.contentSize.height) animated:YES];
To get double tap from UIWebview u need to subclass the UIWindow and use the method, 要从UIWebview双击,您需要继承UIWindow并使用方法,
- (void)sendEvent:(UIEvent *)event {
NSLog(@"tap detect");
NSArray *allTouches = [[event allTouches] allObjects];
UITouch *touch = [[event allTouches] anyObject];
UIView *touchView = [touch view];
if (touchView && [touchView isDescendantOfView:urWebview]) {
//
// touchesBegan
//
if(touch.tapCount==2){
//
// doubletap
//
}
}
}
From this subclass of UIWindow use a delegate or Notification to catch the tap on your class. 在UIWindow的此子类中,使用委托或通知来捕获类上的点击。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.