我是iPhone
开发人员的新手,
我制作了epub阅读器并在我的epub中加载了每一页webview
,当我看到我的portrait mode
滚动应用程序不存在时,我已经使用过,
webview.scalesPageToFit=TRUE;
但是,当我看到我的应用程序在横向模式页面适合但滚动时会发生,所以我想swiperight gesture
在滚动结束时添加,以便用户可以导航到下一页,在做rightswipe
.
有什么方法可以告诉 webview 已完成滚动?
_ 简而言之,如何检测 UIWebView 到达顶部或底部?_
提前致谢 !
EDIT 写入确实加载:
swipeRight = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeRightAction:)];
swipeRight.direction = UISwipeGestureRecognizerDirectionRight;
swipeRight.delegate = (id<UIGestureRecognizerDelegate>)self;
[_webview addGestureRecognizer:swipeRight];
swipeLeft = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeLeftAction:)];
swipeLeft.direction = UISwipeGestureRecognizerDirectionLeft;
swipeLeft.delegate = (id<UIGestureRecognizerDelegate>)self;
[_webview addGestureRecognizer:swipeLeft];
然后在加载每个页面时,我正在检查方向,如果它是纵向的,然后再添加两个向上和向下的手势,如果是横向的,然后删除向上和向下的手势。
if([UIApplication sharedApplication].statusBarOrientation==UIInterfaceOrientationPortrait || [UIApplication sharedApplication].statusBarOrientation==UIInterfaceOrientationPortraitUpsideDown) {
swipeUp = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeLeftAction:)];
swipeUp.direction = UISwipeGestureRecognizerDirectionUp;
swipeUp.delegate = (id<UIGestureRecognizerDelegate>)self;
[_webview addGestureRecognizer:swipeUp];
swipeDown = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeRightAction:)];
swipeDown.direction = UISwipeGestureRecognizerDirectionDown;
swipeDown.delegate = (id<UIGestureRecognizerDelegate>)self;
[_webview addGestureRecognizer:swipeDown];
counterPort++;
counterLand=0;
}
}
if (counterLand==0) {
if([UIApplication sharedApplication].statusBarOrientation==UIInterfaceOrientationLandscapeLeft || [UIApplication sharedApplication].statusBarOrientation==UIInterfaceOrientationLandscapeRight) {
[_webview removeGestureRecognizer:swipeDown];
[swipeDown release];
swipeDown=nil;
[_webview removeGestureRecognizer:swipeUp];
[swipeUp release];
swipeUp=nil;
counterPort=0;
counterLand++;
}
根据您的建议:
-(void)scrollViewDidScroll:(UIScrollView *)scrollView{
float scrollViewHeight = scrollView.frame.size.height;
float scrollContentSizeHeight = scrollView.contentSize.height;
float scrollOffset = scrollView.contentOffset.y;
if (scrollOffset == 0)
{
swipeUp = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeLeftAction:)];
swipeUp.direction = UISwipeGestureRecognizerDirectionUp;
swipeUp.delegate = (id<UIGestureRecognizerDelegate>)self;
[_webview addGestureRecognizer:swipeUp];
}
else if (scrollOffset + scrollViewHeight == scrollContentSizeHeight)
{
swipeDown = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeRightAction:)];
swipeDown.direction = UISwipeGestureRecognizerDirectionDown;
swipeDown.delegate = (id<UIGestureRecognizerDelegate>)self;
[_webview addGestureRecognizer:swipeDown];
}
}