双击UIwebview到全屏

时间:2013-12-16 10:24:18

标签: ios cocoa-touch webview uiwebview

我想双击一个大小为(159,182)的UIwebview我想将它扩展到全屏大小(它覆盖了整个屏幕)我也想要它,能够再次点击完整的webview并且然后让它达到正常大小(159,182)这可能吗?

1 个答案:

答案 0 :(得分:2)

为其添加UITapGestureRecognizer。在viewDidLoad中:

UITapGestureRecognizer *doubleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(doubleTap)];
doubleTap.numberOfTapsRequired = 2;
doubleTap.delegate = self;
[webView addGestureRecognizer:doubleTap];

不要忘记将UIGestureRecognizerDelegate添加到头文件中。

在viewDidUnload中删除UITapGestureRecognizer。

同时添加此方法

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer    *)otherGestureRecognizer {
    return YES;
}

然后实现代码以在

中调整UIWebView的大小
- (void)doubleTap
{
    ...
}