0

私の iPhone アプリケーションでは、Web ビューを使用してユーザー フィードを表示しています。リフレッシュのために、ユーザーが上から上にスクロールしている間にサーバーリクエストを送信しています。これには、クールな種類のリフレッシュを使用したいと思います。

ODRefreshコントローラー(Git- here )を試しましたが、スクロールビューとテーブルビューでのみ機能し、UIWebVIew(アプリがクラッシュします)では機能しません。UIScrollViewメソッドを使用して webview へのデリゲートを実装しましたaddScrollViewListenerが、まだ運がありません。

私のコードは次のとおりです。

- (void)viewDidLoad
{
    [super viewDidLoad];

    ODRefreshControl *refreshControl = [[ODRefreshControl alloc] initInScrollView:self.myWebView];
    [refreshControl addTarget:self action:@selector(dropViewDidBeginRefreshing:) forControlEvents:UIControlEventValueChanged];
}

- (void)dropViewDidBeginRefreshing:(ODRefreshControl *)refreshControl
{
    double delayInSeconds = 3.0;
    dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, delayInSeconds * NSEC_PER_SEC);
    dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
        [refreshControl endRefreshing];
    });
}

- (void) addScrollViewListener
{
    UIScrollView* currentScrollView;
    for (UIView* subView in myWebView.subviews) {
        if ([subView isKindOfClass:[UIScrollView class]]) {
            currentScrollView = (UIScrollView*)subView;
            currentScrollView.delegate = self;
        }
    }
}
4

1 に答える 1

0
ODRefreshControl *refreshControl = [[ODRefreshControl alloc] initInScrollView:[[self.myWebView subviews] objectAtIndex:0]];

または

ODRefreshControl *refreshControl = [[ODRefreshControl alloc] initInScrollView:[[self.myWebView subviews]lastObject]];
于 2013-01-25T07:06:54.087 に答える