小编Dol*_*lly的帖子

如何检测UIWebView的缩放比例

我希望UIWebView在用户放大时增加高度(如iPhone中的默认邮件应用程序).所以,我曾尝试下面的代码,以找到在滚动视图的WebView,并添加UIScrollViewDelegate使用scrollViewDidZoom用于检测缩放比例,以增加这种方法的WebView的高度.

// 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 *) …
Run Code Online (Sandbox Code Playgroud)

iphone zoom uiwebview uiscrollview

4
推荐指数
1
解决办法
6935
查看次数

标签 统计

iphone ×1

uiscrollview ×1

uiwebview ×1

zoom ×1