我正在尝试使用UIDocumentInteractionController OpenIn菜单将我的应用程序中生成的图像发送到其他应用程序.我用这段代码将UIImage保存到磁盘:
fileJpeg = [NSTemporaryDirectory() stringByAppendingPathComponent:@"activeImage.jpg"];
jpegFileURL = [NSURL fileURLWithPath:fileJpeg];
UIImage *imageToWrite = image;
[UIImageJPEGRepresentation(imageToWrite, 1.0) writeToFile:fileJpeg atomically:YES];
Run Code Online (Sandbox Code Playgroud)
我正在使用MFMailComposeViewController通过电子邮件发送图像的另一种方法访问jpegFileURL,它运行正常,因此NSURL是有效的.但是当我尝试将图像发送到另一个应用程序(只是发送,我没有实现任何预览功能)时,应用程序崩溃了.这是方法:
- (IBAction)openInOtherApp:(id)sender{
UIDocumentInteractionController *controller = [UIDocumentInteractionController interactionControllerWithURL: jpegFileURL];
controller.delegate = self;
CGRect rect = self.view.frame;
[controller presentOpenInMenuFromRect:rect inView:self.view animated:YES];
}
Run Code Online (Sandbox Code Playgroud)
显示"打开"菜单.当我点击任何可用应用程序的按钮时,它会崩溃.在iOS6(6.0.1)和iOS5(5.1.1)设备上测试时,我在控制台中没有输出错误(只是通常的EXC_BAD_ACCESS(代码= 1,地址...崩溃),但是在iOS 4.3设备上(应用程序是4.3向上兼容)我在控制台中收到此错误:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFType actionSheet:clickedButtonAtIndex:]: unrecognized selector sent to instance 0x16b7f0'
Run Code Online (Sandbox Code Playgroud)
我一直在阅读关于UIDocumentInteractionController和UIDocumentInteractionControllerDelegate的Apple文档,我在我的类@interface中实现,但似乎不需要任何可选的委托方法来满足我的需求或在此崩溃中有所帮助.
无法想象有什么不对或缺失.任何帮助,将不胜感激.
这是我在stackoverflow上的第一篇文章.我是iOS开发人员新手,我不是母语为英语的人,所以我会尽力解释我的问题.
问题:
我已经在我的AppDelegate窗口中添加了两个视图,我想使用以下方法从一个窗口切换到另一个窗口:
UIView transitionFromView:toView:
Run Code Online (Sandbox Code Playgroud)
第一个视图(MainScreenView)有自己的ViewController.在MainScreenView .xib文件中,我有一个按钮,其动作调用我的AppDelegate中实现的方法"goShow".在那个方法中,我UIView transitionFromView:toView:用来转换到第二个视图.到目前为止一切正常.我的第二个视图(一个scrollview)在我的AppDelegate中以编程方式声明,并且里面有一堆图片(picturesViewController),并且在这些视图之上有一个UIPinchGestureRecognizer.
我正在使用手势识别器来翻回我的MainScreenView.这就是问题所在.当我在滚动视图上执行捏合手势时,会MainScreenView.view立即显示在动画之前,因此翻转动画看起来不对.
我正在使用的代码是:
-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
mainScreen = [[MainScreenViewController alloc] initWithNibName:@"MainScreenViewController" bundle: [NSBundle mainBundle]];
CGRect frame = self.window.bounds;
int pageCount = 10;
scrollView = [[UIScrollView alloc] initWithFrame:frame];
scrollView.contentSize = CGSizeMake(320*pageCount, 480);
scrollView.pagingEnabled = YES;
scrollView.showsHorizontalScrollIndicator = FALSE;
scrollView.showsVerticalScrollIndicator = FALSE;
scrollView.delegate = self;
[...] 'While' adding pictures to de scrollView
UIPinchGestureRecognizer *twoFingerPinch = [[[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(goBackToMain)] autorelease];
[scrollView addGestureRecognizer:twoFingerPinch];
[self.window addSubview: scrollView]; …Run Code Online (Sandbox Code Playgroud) cocoa-touch uiviewcontroller uiviewanimationtransition ios appdelegate