//
// ViewController.m
// test_UIdocument_01
//
// Created by admin on 3/27/16.
// Copyright © 2016 jeffasd. All rights reserved.
//
#import "ViewController.h"
@interface ViewController ()
@property (nonatomic, strong) UIButton * presentButton;
@end
@implementation ViewController
-(void) viewDidLoad {
[super viewDidLoad];
_presentButton = [UIButton buttonWithType: UIButtonTypeCustom];
_presentButton.frame = CGRectMake (100, 100, 200, 200);
_presentButton.backgroundColor = [UIColor redColor];
[self.view addSubview: _presentButton];
}
-(void) touchesBegan: (NSSet <UITouch *> *) touches withEvent: (UIEvent *) event {
NSString * fileString = [[NSBundle mainBundle] pathForResource: @ "ios" ofType: @ "pdf"];
//// NSURL * fileUrl = [NSURL URLWithString: fileString];
//
NSURL * fileUrl = [[NSBundle mainBundle] URLForResource: @ "ios" withExtension: @ "pdf"];
//
// NSLog (@ "the fileUrl is% @", fileUrl);
//
// NSURL * testFileUrl = [NSURL fileURLWithPath: fileString];
//
// NSLog (@ "the file url is% @", testFileUrl);
//
// NSString * string1 = fileUrl.path;
//
// NSArray * array = fileUrl.pathComponents;
//
// NSString * string2 = fileUrl.parameterString;
// [NSFileManager];
UIDocumentInteractionController * documentController = [UIDocumentInteractionController interactionControllerWithURL: fileUrl]; // This appears in writing
<p class= "P1" ><span class= "S1" ><strong>2016-03-27 14:20:08.253 test_uidocument_01[743:44711]-[ Nsmachport _opendocumentwithapplication:]: Unrecognized selector sent to instance 0x170169fc0</strong></span ></p><p class= "P1" ><span class= ' s1 ' ><strong>2016-03-27 14:20:08.255 test_UIdocument_01[ 743:44711] * * * terminating app due to uncaught exception ' nsinvalidargumentexception ', Reason: '-[nsmachport _opendocumen Twithapplication:]: Unrecognized selector sent to instance 0x170169fc0 ' </strong></span></p><p Class= "P1" ><span class= "S1" ><strong>***-A-throw call stack:</strong></span></p ><p class= "P1" ><span class= "S1" ><strong> (0x18673822c 0x1981a80e4 0x18673f2f4-0x18673c0a8 0x18663e96c 0x18b701a80 0x18b89a7f4 0x18b4baab0 0x18b4bcf2c 0x18b2d6db8 0x18b1ec55c 0x18b1ec0c4 0X18B1EBFCC 0x18aaf562c 0x1000bcf94 0x1000c1c28 0x1866ef544 0x1866ed5ec 0x186618f74 0X18FF3B6FC1ad94 0x100084960 0x198852a08) </strong></span></p><p class= "P1" ><span class= "S1" > <strong>libc++abi.dylib:terminating with uncaught exception of type nsexception</strong></span> </p><p class= "P2" ><span class= "S1" ><strong> (LLDB) </strong></span></ P> the reason for this error is that:<div> consulted the documentation on the Apple developer, which originally showed <code>uidocumentinteractioncontroller</in the ARC environment Code>, when my function method call is complete, the,<code>uidocumentinteractioncontroller</code> instance is released after the stack is dropped, and the view displayed by < Code>quick look</code> Framework, and does not generate references to <code>UIDocumentInteractionController</code>. When you click on the button on the view, the internal operation will still continue to access the <code>UIDocumentInteractionController</code> instance, and you will report the above error.
</div>//[Documentcontroller presentOpenInMenuFromRect:self.view.bounds InView:self.view Animated:yes];
UIView *view = [UIView new];
View.frame = CGRectMake (100, 200, 300, 300); View.backgroundcolor = [UicolorCyancolor];
[Self.view Addsubview:view]; [Documentcontroller presentopeninmenufromrect:cgrectmake (MB, inView:self.view) Animated:yes];
}
-(void) didreceivememorywarning {
[super didreceivememorywarning];
Dispose of any of the can is recreated.
}
@end