我创建的应用程序与ios 7和ios 8兼容,但ios 7 delegete上的UIWebview从未调用过,我得到了
void SendDelegateMessage(NSInvocation *):delegate (web视图:decidePolicyForNavigationAction:请求:帧:decisionListener :) 等了10秒后没能回来。主运行循环模式: kCFRunLoopDefaultMode
我在网上搜索但没有解决方案 4天尝试没有幸运..
class AWTncViewController: UIViewController, UIWebViewDelegate{
@IBOutlet weak var wv: UIWebView!
deinit {
NSNotificationCenter.defaultCenter().removeObserver(self)
wv.delegate = nil
}
override func viewDidLoad() {
super.viewDidLoad()
super.viewDidLoad()
self.wv.delegate = self;
let myHTMLString:String! = "<h1>Hello word!</h1>"
self.wv.loadHTMLString(myHTMLString, baseURL: nil)
}
override func viewDidAppear(animated: Bool) {
super.viewDidAppear(animated)
/* Test 2 still not load
let myHTMLString:String! = "<h1>Hello word!</h1>"
self.wv.loadHTMLString(myHTMLString, baseURL: nil)
*/
}
func webView(webView: UIWebView, shouldStartLoadWithRequest request: NSURLRequest, navigationType: UIWebViewNavigationType) -> Bool {
//this never called
println("shouldStartLoadWithRequest execute")
return true
}
func webView(webView: UIWebView, shouldStartLoadWithRequest request: NSURLRequest, navigationType: UIWebViewNavigationType) -> Bool
{
//this never called
println("shouldStartLoadWithRequest execute")
return true
}
func webViewDidStartLoad(webView: UIWebView)
{
//this never called
println("Start load")
}
func webViewDidFinishLoad(webView: UIWebView)
{
//this never called
println("FinishLoad")
}
func webView(webView: UIWebView, didFailLoadWithError error: NSError)
{
//this never called
println("didFailLoadWithError: \(error.description)")
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
}
我读到了这个:iOS 7 UIWebView not rendering
但我不是在使用Crittercism
答案 0 :(得分:0)
我也遇到过这个问题。似乎问题是在链接某些第三方库时引起的,但我甚至不确定在我的情况下究竟是哪一个负责。
为我修复的是我发现here on Apple's Dev Forum提前UIWebView
实例化的建议。
- (BOOL)application:(UIApplication *)application willFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// In a severe case of WTF: some 3rd party libs (exact culprit unknown) can cause webviews to stop
// showing anything on iOS 7, and instead have console warnings every 10 seconds that look like:
// void SendDelegateMessage(NSInvocation *): delegate (webView:decidePolicyForNavigationAction:request:frame:decisionListener:) failed to return after waiting 10 seconds. main run loop mode: kCFRunLoopDefaultMode
// Just instantiating an UIWebView before any of the 3rd party libs kick in is enough to fix it.
// Don't know why, but it works.
if (SYSTEM_VERSION_LESS_THAN(@"8.0")) {
UIWebView *webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 320)];
webView.delegate = nil; // Do something with webView to silence warning
}
return YES;
}