我想在我的应用程序中,电子邮件ID是以文本形式写在课程外,但该文本应该是可点击的。点击该弹出窗口应显示有两个字段和两个按钮。这两个字段应该是可编辑的,以便在其中键入“from”和“message body”。两个按钮是发送和取消。 请帮忙。
答案 0 :(得分:0)
只需使用您的电子邮件地址创建按钮,并在其上设置选择器,如下所示......
UIButton *BtnEmail = [UIButton buttonWithType:UIButtonTypeCustom];
[BtnEmail setBackgroundColor:[UIColor clearColor]];
[BtnEmail setTitle:@"YourEmailId" forState:UIControlStateNormal];
BtnEmail.frame = CGRectMake(85, 100, 150, 39 );/// set your frame
[BtnEmail addTarget:self action:@selector(EmailButtonClicked:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:BtnEmail];
并在操作事件(方法)中编写此代码..只需在.h
文件MFMessageComposeViewControllerDelegate
和MFMailComposeViewControllerDelegate
中添加这两个代理,并且1个框架名称为MessageUI.framework
-(IBAction)EmailButtonClicked:(id)sender{
if ([MFMailComposeViewController canSendMail]) {
appDelegate.imgCapture = [self captureView];
[appDelegate.imgCapture retain];
MFMailComposeViewController *mailComposeViewController = [[MFMailComposeViewController alloc] init];
NSString *mailBody = @"Set Your Body Message";
[mailComposeViewController setMessageBody:mailBody isHTML:NO];
mailComposeViewController.mailComposeDelegate = self;
[self presentViewController:mailComposeViewController animated:YES completion:nil];
} else {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"e-Mail Sending Alert"
message:@"You can't send a mail"
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
[alert release];
}
}
这些波纹管方法是Delegate方法..
#pragma mark - MFMessage Delegate
- (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result
{
[self dismissViewControllerAnimated:YES completion:nil];
}
- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error
{
[self dismissViewControllerAnimated:YES completion:nil];
}
我希望这可以帮助你...