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

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

问题描述

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

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

如果我触摸此站点中的视图或播放音频,有时我的应用程序会崩溃,而有时却没有,为什么?
是因为html5吗?怎么解决?其他网站没问题.

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.

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

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

非常感谢任何帮助

---更新---

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

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

这次是崩溃日志

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'

项目中的源码,这次不用MPMoviePlayerController什么的了

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 表示您的代码中某处有一个 MPTransportButton 之前已被释放(释放),之后,您的代码中的其他地方,您想做某事用它.

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.

我认为您在 UIWebView 的委托方法之一中执行此操作.

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

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

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天全站免登陆