UIWebView load crash [__NSCFDictionary _isChargeEn

2019-02-20 22:09发布

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
{
}

1条回答
我命由我不由天
2楼-- · 2019-02-20 22:49

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?

查看更多
登录 后发表回答