我是iOS的新手。我想在iOS中添加PDF文档。我尝试了两种选择。 iOS中的URL和文档。但是当我尝试使用URL打开PDF时,我得到空白页面。当我尝试使用pdf文档时,我在Xcode上遇到错误。
我为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];
我试试这个文件
NSString *path = [[NSBundle mainBundle] pathForResource:@"document" ofType:@"pdf"];
NSURL *targetURL = [NSURL fileURLWithPath:path];
NSURLRequest *request = [NSURLRequest requestWithURL:targetURL];
[webView loadRequest:request];
是关于故事板的吗?因为我不使用.xib
我收到此错误。
2014-03-06 01:38:49.635 YGS [3934:70b] *由于未捕获的异常'NSGenericException'而终止应用程序,原因是:'推送segues只能在源控制器由UINavigationController的实例。' * 第一次抛出调用堆栈: ( 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执行:] + 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:以NSException类型的未捕获异常终止 (lldb)
答案 0 :(得分:0)
是的Ozgur它与您的故事板有关 - “'推送segues只能在源控制器由UINavigationController实例管理时使用。”
它告诉你问题是什么 - 你正在使用一个类型push的segue,它试图在源视图控制器不是UINavigationController时推送目标视图控制器。更改segue的类型或更改源视图控制器的类型,以最适合您的GUI设计。