iOS如何检查是否转到webView的底部

标签 ios webview

有什么事件可以通知supper view吗?

我尝试使用 scrollViewDidScroll。但它不会被调用。

-(void)scrollViewDidScroll: (UIScrollView*)scrollView
{
    NSLog(@"At the bottom...");
}

最佳答案

必须先将webview中scrollview的delegate设置为self。这样,当您滚动 webview 时,可以调用 scrollViewDidScroll:。所以,试试这个:

- (void)viewDidLoad
{
    [super viewDidLoad];
    self.webview.scrollview.delegate = self;
}

- (void)scrollViewDidScroll:(UIScrollView*)scrollview
{
    CGPoint offset = scrollView.contentOffset;

    CGRect bounds = scrollView.bounds;

    UIEdgeInsets inset = scrollView.contentInset;

    CGFloat currentOffset = offset.y + bounds.size.height - inset.bottom;

    if (currentOffset - scrollView.contentSize.height <= 0)
    {
        NSLog(@"At the bottom...");
    }
}

关于iOS如何检查是否转到webView的底部,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25521469/

相关文章:

ios - 使用 UICollectionViewController 时如何为 UICollectionView 添加居中的 UIActivityIndi​​cator?

iphone - bundle 访问中的sqlite db路径?

JavascriptInterface 与 Phonegap。 (安卓网络应用程序)

ios - 在 CSV 文件的新行中添加新数据

objective-c - 防止 AlertView 解雇

ios - Xcode IB : UIButton hidden but have still buttons space

android - 如何使用android_asset

javascript - 如何在 WebView [React-Native] 中禁用用户文本选择

java - 可以加载到 Android WebView 中的最大 html 文件是多少?

android - ScrollView 中的 WebView 每次向上滑动 React Native Android 时调用 refreshControl