佚名通过本文主要向大家介绍了wkwebview 加载pdf,wkwebview,ios wkwebview,wkwebview内核,swift wkwebview等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com
问题: 关于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页面呢?跪求各路大神指点
解决方案1:
描述:
WKWebViewiOS混合开发移动开发
现在在做一个项目,首页是原生的,然后页面上有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页面呢?跪求各路大神指点
解决方案1:
hotelVC = [[YNHotelController alloc] init];
你只是把这个vc创建出来,没有调用他的view,这样的话是不会执行到viewDidLoad这个方法的,我估计你大部份的加载动作都是放在这个方法,或者生命周期在这个方法之后的其他方法里
你可以设置断点看看
解决的办法其实挺土的
你再后面加一句
hotelVC.view;这样就可以了(编译器会有黄色的警告,可以不管他)