UIWebView加载崩溃[__NSCFDictionary _isChargeEnabled] [英] UIWebView load crash [__NSCFDictionary _isChargeEnabled]

查看:482
本文介绍了UIWebView加载崩溃[__NSCFDictionary _isChargeEnabled]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用UIWebView加载此网站 http://www.xiami.com/song/1024665



有时候我的应用程序崩溃,如果我触摸视图或播放音频在这个网站,有时它不,为什么?

因为html5?如何解决?
其他网站没有问题。



崩溃日志是
* - [MPTransportButton _isChargeEnabled]:消息发送到deallocated实例0x20aa58d0



任何帮助非常感谢



---更新---



我创建一个新的视图基础项目,ViewController中的代码如下



这次,崩溃日志是

  2011-08-16 18:11:25.450 WebTest [1291:707]  -  [__ NSCFDictionary _isChargeEnabled]:无法识别的选择器发送到实例0x1ede0a10 
2011-08-16 18:11:25.462 WebTest [1291:707] ***由于未捕获异常而终止应用程序'NSInvalidArgumentException',reason:' - [__ NSCFDictionary _isChargeEnabled]:无法识别的选择器发送到实例0x1ede0a10'
***首次调用堆栈:

0 CoreFoundation 0x30ea764f __exceptionPreprocess + 114
1 libobjc.A.dylib 0x349c2c5d objc_exception_throw + 24
2 CoreFoundation 0x30eab1bf - [NSObject (NSObject)doesNotRecognizeSelector:] + 102
3 CoreFoundation 0x30eaa649 ___ forwarding___ + 508
4 CoreFoundation 0x30e21180 _CF_forwarding_prep_0 + 48
5 UIKit 0x30f232bd - [UIWindow warpPoint:] + 200
6 UIKit 0x30f0c1d5 _UIApplicationHandleEvent + 2404
7 GraphicsServices 0x30790e77 PurpleEventCallback + 666
8的CoreFoundation 0x30e7ea97 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 26
9的CoreFoundation 0x30e8083f __CFRunLoopDoSource1 + 166
10的CoreFoundation 0x30e8160d __CFRunLoopRun + 520
11的CoreFoundation 0x30e11ec3 CFRunLoopRunSpecific + 230
12 CoreFoundation 0x30e11dcb CFRunLoopRunInMode + 58
13 GraphicsServices 0x3079041f GSEventRunModal + 114
14 GraphicsServices 0x307904cb GSEventRun + 62
15 UIKit 0x30f37d69 - [UIApplication _run] + 404
16 UIKit 0x30f35807 UIApplicationMain + 670
17 WebTest 0x00013425 main + 48
18 WebTest 0x000133f0 start + 40

在抛出NSException实例后调用终止



项目中的源代码,不使用MPMoviePlayerController此时或其他

   - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil 
{
self = [self init];
return self;
}

- (id)init
{
if(self = [super initWithNibName:nil bundle:nil])
{
}
return self;
}

- (void)viewDidLoad
{
[super viewDidLoad];

UIWebView * web = [[UIWebView alloc] initWithFrame:CGRectMake(0,0,320,460)];
[web loadRequest:[NSURLRequest requestWithURL:
[NSURL URLWithString:@http://www.xiami.com/song/1024665]]];
web.delegate = self;
[self.view addSubview:web];
[web release];
}

- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
{
return YES;
}
- (void)webViewDidStateLoad:(UIWebView *)webView
{
}
- (void)webViewDidFinishLoad:
// [webView stringByEvaluatingJavaScriptFromString:@window.scrollTo(0,10);];
}
- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error
{
}
pre>

解决方案

您发布的代码没有问题。



NSZombie 说,在你的代码中有一个 MPTransportButton 以前被释放(释放),之后,其他地方



我认为你可以在你的 UIWebView 的委托方法。



但是... 我们需要更多代码。你 alloc / init 你的 MPMoviePlayerController 在哪里?或者你 alloc / init a MPTransportButton



$ b b

I use UIWebView to load this site http://www.xiami.com/song/1024665

sometimes my app crashes if I touch the view or play the audio in this site and sometimes it does not, why?
is it because html5? how to solve? other website is no problem.

crash log is * -[MPTransportButton _isChargeEnabled]: message sent to deallocated instance 0x20aa58d0

any help is much appreciated

---update---

I create a new view-base project, the code in ViewController is as following

This time, the crash log is

2011-08-16 18:11:25.450 WebTest[1291:707] -[__NSCFDictionary _isChargeEnabled]: unrecognized selector sent to instance 0x1ede0a10
2011-08-16 18:11:25.462 WebTest[1291:707] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFDictionary _isChargeEnabled]: unrecognized selector sent to instance 0x1ede0a10'
*** Call stack at first throw:
(
    0   CoreFoundation                      0x30ea764f __exceptionPreprocess + 114
    1   libobjc.A.dylib                     0x349c2c5d objc_exception_throw + 24
    2   CoreFoundation                      0x30eab1bf -[NSObject(NSObject) doesNotRecognizeSelector:] + 102
    3   CoreFoundation                      0x30eaa649 ___forwarding___ + 508
    4   CoreFoundation                      0x30e21180 _CF_forwarding_prep_0 + 48
    5   UIKit                               0x30f232bd -[UIWindow warpPoint:] + 200
    6   UIKit                               0x30f0c1d5 _UIApplicationHandleEvent + 2404
    7   GraphicsServices                    0x30790e77 PurpleEventCallback + 666
    8   CoreFoundation                      0x30e7ea97 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 26
    9   CoreFoundation                      0x30e8083f __CFRunLoopDoSource1 + 166
    10  CoreFoundation                      0x30e8160d __CFRunLoopRun + 520
    11  CoreFoundation                      0x30e11ec3 CFRunLoopRunSpecific + 230
    12  CoreFoundation                      0x30e11dcb CFRunLoopRunInMode + 58
    13  GraphicsServices                    0x3079041f GSEventRunModal + 114
    14  GraphicsServices                    0x307904cb GSEventRun + 62
    15  UIKit                               0x30f37d69 -[UIApplication _run] + 404
    16  UIKit                               0x30f35807 UIApplicationMain + 670
    17  WebTest                             0x00013425 main + 48
    18  WebTest                             0x000133f0 start + 40
)
terminate called after throwing an instance of 'NSException'

the source code in the project, not use MPMoviePlayerController this time or something else

 - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [self init];
    return self;
}

- (id)init
{
    if (self = [super initWithNibName:nil bundle:nil])
    {
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];

    UIWebView *web = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 460)];
    [web loadRequest:[NSURLRequest requestWithURL:
                      [NSURL URLWithString:@"http://www.xiami.com/song/1024665"]]];
    web.delegate = self;
    [self.view addSubview:web];
    [web release];
}

- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
{
    return YES;
}
- (void)webViewDidStartLoad:(UIWebView *)webView
{
}
- (void)webViewDidFinishLoad:(UIWebView *)webView
{
    //[webView stringByEvaluatingJavaScriptFromString:@"window.scrollTo(0, 10);"];
}
- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error
{
}

解决方案

There's nothing wrong in code that you posted.

NSZombie says that there is a MPTransportButton somewhere in your code that was previously deallocated (released) and after that, somewhere else in your code, you want to do something with it.

I think that you do it in one of your UIWebView's delegate methods.

But... we need more code. Where do you alloc/init your MPMoviePlayerController? Or do you alloc/init a MPTransportButton?

这篇关于UIWebView加载崩溃[__NSCFDictionary _isChargeEnabled]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆