gpt4 book ai didi

iphone-sdk-3.0 - 在iPhone 3.0中,尝试使用MessageUI从相机发送图像时,应用程序崩溃

转载 作者:行者123 更新时间:2023-12-03 16:18:02 24 4
gpt4 key购买 nike

我正在开发iPhone应用程序的一部分,您可以在其中使用iPhone 3.0中的应用程序内邮件发送图像。从相机胶卷中选择图像效果很好,但是当我尝试从相机到电子邮件(即-从UIImagePickerController到MFMailComposeViewController)时,应用程序崩溃。

这是运行相机的代码:

- (BOOL)startCameraPickerFromViewController:(UIViewController*)controller usingDelegate:(id<UIImagePickerControllerDelegate, UINavigationControllerDelegate>)delegateObject 
{
if ( (![UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) || (delegateObject == nil) || (controller == nil))
return NO;
UIImagePickerController* picker = [[UIImagePickerController alloc] init];
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
picker.delegate = delegateObject;
picker.allowsImageEditing = NO;
[controller presentModalViewController:picker animated:YES];
return YES;
}

这是完成摄像头的代码:
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo
{
NSLog(@"Called finish picking");
self.imageForSending = theImage;

// NSData *imageData = UIImageJPEGRepresentation(image, 1);

[[picker parentViewController] dismissModalViewControllerAnimated:YES];
[(ChannelTwoAppDelegate *) [[UIApplication sharedApplication] delegate] recoverNavigationBar];

[self performSelector:@selector(sendEmail) withObject:nil afterDelay:0.45];
[picker release];
}

这是发送邮件的代码:
- (void) sendEmail {

[(ChannelTwoAppDelegate *) [[UIApplication sharedApplication] delegate] hideNavigationBar];
if (![MFMailComposeViewController canSendMail])
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"שגיאה", @"") message:NSLocalizedString(@"לא ניתן לשלוח מייל ממכשיר זה", @"")
delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil];
[alert show];
[alert release];
}
else
{
MFMailComposeViewController *controller = [[MFMailComposeViewController alloc] init];
controller.mailComposeDelegate = self;
[[controller navigationBar] setTintColor:[UIColor colorWithRed:120.0/255.0 green:0 blue:0 alpha:1.0]];
NSData *imageData = UIImageJPEGRepresentation(imageForSending, 1);
[controller addAttachmentData:imageData mimeType:@"image/jpg" fileName:@"storyImage.jpg"];
[controller setSubject:@""];
[controller setToRecipients:[NSArray arrayWithObject:@""]];
[self presentModalViewController:controller animated:YES];
[controller release];
}

}

由于相关性较低,因此我删除了电子邮件地址和主题。

崩溃发生在电子邮件的presentModalViewController上。再次-从相机胶卷中选择图像时,此精确代码可以完美地工作...

帮帮我 ?
我已经和这个战斗了一段时间了,真的可以使用一些新的输入。
谢谢!

最佳答案

大家看的嗨,我找到了自己问题的答案。
这是两个模态 View Controller 的演示之间的时间问题

基本上,我已经知道这是一个问题,但是,我没有等待足够长的时间。
等待足以从相机胶卷中选择图像,但又不够长,无法从相机中回来。

[使用对象:零,延迟:0.45后,自我selfSelectSelector:@selector(sendEmail)];

变成 :

[自我performSelector:@selector(sendEmail),对象:无,延迟:1.0];

我还添加了一个UIActivityIndi​​cator来指示该用户正在发生某些事情。

编码愉快!

关于iphone-sdk-3.0 - 在iPhone 3.0中,尝试使用MessageUI从相机发送图像时,应用程序崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1392583/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com