我希望在我的应用程序中,电子邮件 ID 以文本形式书写,但该文本应该是可点击的。单击该弹出窗口时,应该会出现两个字段和两个按钮。这两个字段应该是可编辑的,以便在其中键入“发件人”和“消息正文”。两个按钮是发送和取消。请帮忙。
问问题
93 次
1 回答
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];
}
}
这些波纹管方法是委托方法..
#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];
}
我希望这可以帮助你...
于 2012-11-29T10:04:52.013 回答