0
votes

I'm new in iOS. I want to add PDF document in iOS. I try two options. URL and Document in iOS. But When I try open PDF with URL I get empty page. When I try with pdf document I get error on Xcode.

I try this for URL

CGRect rect = [[UIScreen mainScreen] bounds];
CGSize screenSize = rect.size;

UIWebView *webView = [[UIWebView alloc] initWithFrame:CGRectMake(10, 10, 200, 200)];

NSURL *targetURL = [NSURL URLWithString:@"http://dokuman.osym.gov.tr/pdfdokuman/2012/OSYS/2012YGSSorular.pdf"];
NSURLRequest *request = [NSURLRequest requestWithURL:targetURL];
[webView loadRequest:request];

I try this one for document

NSString *path = [[NSBundle mainBundle] pathForResource:@"document" ofType:@"pdf"];
NSURL *targetURL = [NSURL fileURLWithPath:path];
NSURLRequest *request = [NSURLRequest requestWithURL:targetURL];
[webView loadRequest:request];

Is it about storyboard? Because I dont use .xib

I get this error.

2014-03-06 01:38:49.635 YGS[3934:70b] * Terminating app due to uncaught exception 'NSGenericException', reason: 'Push segues can only be used when the source controller is managed by an instance of UINavigationController.' * First throw call stack: ( 0 CoreFoundation 0x017395e4 exceptionPreprocess + 180 1 libobjc.A.dylib 0x014bc8b6 objc_exception_throw + 44 2 UIKit 0x0076eca5 -[UIStoryboardPushSegue destinationContainmentContext] + 0 3 UIKit 0x0075f07e -[UIStoryboardSegueTemplate _perform:] + 174 4 UIKit 0x0075f0f9 -[UIStoryboardSegueTemplate perform:] + 115 5 libobjc.A.dylib 0x014ce874 -[NSObject performSelector:withObject:withObject:] + 77 6 UIKit 0x0022c0c2 -[UIApplication sendAction:to:from:forEvent:] + 108 7 UIKit 0x0022c04e -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 61 8 UIKit 0x003240c1 -[UIControl sendAction:to:forEvent:] + 66 9 UIKit 0x00324484 -[UIControl _sendActionsForEvents:withEvent:] + 577 10 UIKit 0x00323733 -[UIControl touchesEnded:withEvent:] + 641 11 UIKit 0x0059ec7f _UIGestureRecognizerUpdate + 7166 12 UIKit 0x0026919a -[UIWindow _sendGesturesForEvent:] + 1291 13 UIKit 0x0026a0ba -[UIWindow sendEvent:] + 1030 14 UIKit 0x0023de86 -[UIApplication sendEvent:] + 242 15 UIKit 0x0022818f _UIApplicationHandleEventQueue + 11421 16 CoreFoundation 0x016c283f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION + 15 17 CoreFoundation 0x016c21cb __CFRunLoopDoSources0 + 235 18 CoreFoundation 0x016df29e __CFRunLoopRun + 910 19 CoreFoundation 0x016deac3 CFRunLoopRunSpecific + 467 20 CoreFoundation 0x016de8db CFRunLoopRunInMode + 123 21 GraphicsServices 0x036de9e2 GSEventRunModal + 192 22 GraphicsServices 0x036de809 GSEventRun + 104 23 UIKit 0x0022ad3b UIApplicationMain + 1225 24 YGS 0x0000305d main + 141 25 libdyld.dylib 0x01d77701 start + 1 26 ??? 0x00000001 0x0 + 1 ) libc++abi.dylib: terminating with uncaught exception of type NSException (lldb)

1
I copy pasted your code, and it works fine for me. Did you make sure to [self.view addSubview:webView] ? And double check your internet connection. Also it's a 52 page document, so on a slow connection it might take a while to load.SethHB
Definitely share the error.noobzilla
Waited 2 hours but It did not work. Is it about .storyboard? Because I dont use .xib.Ozgur

1 Answers

0
votes

Yes Ozgur it is to do with your storyboard - "'Push segues can only be used when the source controller is managed by an instance of UINavigationController."

It tells you what the problem is - you are using a segue of type push which is trying to push a destination view controller when the source view controller is not a UINavigationController. Change the type of the segue or change the type of the source view controller, whichever is most appropriate for your GUI design.