尝试在文本字段的应用程序电子邮件中添加
它似乎有效,但我在我的 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];
}
}
It seems to be working but I am getting a compile warning inside of my showEmailModalView method on the line: picker.mailComposeDelegate = self; It says "Passing MyAppViewController *const_strong to parameter of incompatible type 'id" If anyone can help with this I will appreciate it.
- (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];
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看起来有人不遵守 MFMailComposeViewControllerDelegate。将其放入 .h 文件中的一对
<>
中,看看当您再次构建并运行时错误是否消失。Looks like somebody isn't conforming to the MFMailComposeViewControllerDelegate. Put it in a pair of these
<>
in the .h file and see if the error goes away when you build and run again.