Кажется, что это работает, но я получаю предупреждение компиляции внутри моего метода showEmailModalView на строке: picker.mailComposeDelegate = self; Там написано: «Передача MyAppViewController * const_strong параметру несовместимого типа id». Если кто-то может помочь с этим, я буду признателен.
- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error
{
switch (result)
{
case MFMailComposeResultCancelled:
break;
case MFMailComposeResultSaved:
break;
case MFMailComposeResultSent:
break;
case MFMailComposeResultFailed:
break;
default:
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Email" message:@"Sending Failed - Unknown Error :-("
delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil];
[alert show];
}
break;
}
[self dismissModalViewControllerAnimated:YES];
}
-(void) showEmailModalView {
MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
picker.mailComposeDelegate = self;
backUpTape = tapeDisplay.text;
[picker setMessageBody:backUpTape isHTML:NO];
picker.navigationBar.barStyle = UIBarStyleBlack;
[self presentModalViewController:picker animated:YES];
}
- (void) alertView: (UIAlertView *) alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if (buttonIndex == 1) {
UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
[pasteboard setValue:tapeDisplay.text forPasteboardType:@"public.utf8-plain-text"];
} else if (buttonIndex == 2)
[self showEmailModalView];
}
- (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [touches anyObject];
CGPoint location = [touch locationInView: self.view];
if (CGRectContainsPoint(tapeDisplay.frame, location)) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle: @"Copy"
message: @""
delegate: self cancelButtonTitle: @"Cancel"
otherButtonTitles: @"Copy", @"email", nil];
[alert show];
}
}