在问我的问题之前,我曾尝试在 stackoverflow 和谷歌中进行大量搜索。似乎是类似的问题,但对我来说没有答案。所以我想问问!!
我有一个视图控制器,显示为 presentModalViewController,里面有一个 uitoolbar 和一个 uiwebview。在 web 视图中显示一个 pdf 文件。Web 视图默认允许我选择文本并向我显示标准 UIMenuController 的复制功能。此时,如果我关闭视图控制器,则应用程序崩溃并在控制台中显示此记录的错误:
libobjc.A.dylib`objc_msgSend:
0x372daf68: teq.w r0, #0
0x372daf6c: beq 0x372dafaa ; objc_msgSend + 66
0x372daf6e: push.w {r3, r4}
0x372daf72: ldr r4, [r0]
0x372daf74: lsr.w r9, r1, #2
0x372daf78: ldr r3, [r4, #8]
0x372daf7a: add.w r3, r3, #8
0x372daf7e: ldr r12, [r3, #-8]
0x372daf82: and.w r9, r9, r12
0x372daf86: ldr.w r4, [r3, r9, lsl #2]
0x372daf8a: teq.w r4, #0
0x372daf8e: add.w r9, r9, #1
0x372daf92: beq 0x372dafa6 ; objc_msgSend + 62
0x372daf94: ldr.w r12, [r4]
0x372daf98: teq.w r1, r12
0x372daf9c: bne 0x372db17e ; objc_msgSendSuper_stret + 34
0x372daf9e: ldr.w r12, [r4, #8]
0x372dafa2: pop {r3, r4}
0x372dafa4: bx r12
0x372dafa6: pop {r3, r4}
0x372dafa8: b 0x372dafb0 ; objc_msgSend_uncached
0x372dafaa: mov.w r1, #0
0x372dafae: bx lr
我不明白这是否是我的 uiwebview 错误 oa 错误
我也尝试使用 CGPDFDocument 来呈现 pdf 页面,但我无法显示 UIMenuController 并选择文本并在文档内执行标准复制操作。我也尝试从这个出色的项目开始,但在这个项目中我也无法执行复制操作 - https://github.com/vfr/Reader
基本上这些是使用的代码。我正在使用带有 ARC 的 iOS 5
- (void)viewDidLoad
{
[super viewDidLoad];
if (![urlPdfFile hasPrefix:@"http"]) {
NSString *ofType = [urlPdfFile pathExtension];
NSString *pathForResource = [[[urlPdfFile lastPathComponent] componentsSeparatedByString:@"."] objectAtIndex:0];
NSString *inDirectory = [urlPdfFile stringByDeletingLastPathComponent];
NSString *url = [[NSBundle mainBundle] pathForResource:pathForResource
ofType:ofType
inDirectory:inDirectory];
[self loadCatalogueFile:url];
} else {
[self loadFile:urlPdfFile];
}
}
- (void)viewDidUnload
{
[self setMyWebView:nil];
[super viewDidUnload];
}
-(void)viewDidDisappear:(BOOL)animated {
[super viewDidDisappear:animated];
[self.view removeFromSuperview];
self.view=nil;
[self viewDidUnload];
}
-(void)loadCatalogueFile:(NSString*)url {
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL fileURLWithPath:url]];
[myWebView loadRequest:request];
}
-(void)loadFile:(NSString*)url
{
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:url]];
[myWebView loadRequest:request];
}
-(void) webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error
{
//
}
-(void)webViewDidFinishLoad:(UIWebView *)webView
{
//
}
- (void)webViewDidStartLoad:(UIWebView *)webView {
//
}
非常感谢您的帮助!!!