Search code examples
iphoneobjective-cios5uiwebviewuiscrollview

App is crashing with NSInvalidArgumentException


I have created a pdf file and I am storing it in my local database. When I load that PDF in my webview it is successfully loading but when I scroll down and I am about to reach the last page my app is crashing saying that(this is happening only in iOS5 in iOS4 it is running fine):

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: -[__NSArrayM insertObject:atIndex:]: object cannot be nil' First throw call stack:
(0x35b0088f 0x33724259 0x35a551d7 0x335a2307 0x335a29bf 0x335a2d4d 0x335a2e29 0x3325acc5 0x332298ef 0x33325cab 0x333251ff 0x33302637 0x33292d65 0x334c3479 0x3320ef55 0x3320daa3 0x3321a7e9 0x3321a627 0x3321a1f5 0x33200695 0x331fff3b 0x337f222b 0x35ad4523 0x35ad44c5 0x35ad3313 0x35a564a5 0x35a5636d 0x337f1439 0x3322ecd5 0x2fe3 0x2f98)
terminate called throwing an exceptionProgram received signal: “SIGABRT”. Data Formatters temporarily unavailable, will re-try after a 'continue'. (Can't find dlopen function, so it is not possible to load shared libraries.)

when I searched I got this link. A they said is it the problem with iOS or anything else?

NSURL *targetUrl = [NSURL fileURLWithPath:webViewStr];
NSURLRequest *request = [NSURLRequest requestWithURL:targetUrl];
[webView loadRequest:request];

Solution

  • The reason it does not work with IOS5 is that IOS 5 does not support javascript. You can navigate through your Pdf using webView.scrollView instead using CGPointMake(x, y)

    read this so answer