1. 程式人生 > >關於WKWebView載入完畢的代理方法

關於WKWebView載入完畢的代理方法


現在在做一個專案,首頁是原生的,然後頁面上有10個左右的button,點選連結H5頁面;
需求:在點選button的時候,當前頁面出現loading動畫,在H5頁面載入完畢後跳轉
我的思路:在button action的方法中,只是alloc init一個H5頁面,在H5頁面載入完畢的代理方法中發出Notification,然後在首頁新增監聽Notification,push頁面.

button action的程式碼:

        self.aniCoverView.hidden = NO;
        self.gifView.image = [UIImage sd_animatedGIFNamed:@"aniGif"];
        [YKBNotificationCenter addObserver:self selector:@selector(closeAnimation:) name:YKBCloseAniNotification object:nil];
        hotelVC = nil;
        hotelVC = [[YNHotelController alloc] init];

H5頁面中載入完畢傳送的Notification:

       [YKBNotificationCenter postNotificationName:YKBCloseAniNotification object:nil userInfo:@{YKBURLString : self.urlString}];

首頁監聽Notification的方法:

           NSString * tempString = notifi.userInfo[YKBURLString];
            if ([tempString containsString:@"Flight/Search/"]) {
            jiPiaoVC.hidesBottomBarWhenPushed = YES;
            [self.tabBarController.parentViewController.navigationController pushViewController:jiPiaoVC animated:YES];
            [YKBNotificationCenter removeObserver:self name:YKBCloseAniNotification object:nil];
        }

現在有個問題:在跳轉後頁面會先白屏,然後才出現H5頁面內容,怎樣才能避過白屏,直接顯示H5頁面呢?跪求各路大神指點