[英]MFMailComposeViewController for Two different labels
My problem is i have a view with a label, wherein, the data on label is coming from web service and on tapping it mail box should appear.In a nutshell it is a mailLabel. 我的问题是我有一个带有标签的视图,其中,标签上的数据来自Web服务,点击它时应该出现邮箱。简而言之,它是一个mailLabel。 Similarly on the same view i have a custom cell which too has another mail label and the same thing should happen,but the mail address will be different and dynamic.
同样,在同一视图上,我有一个自定义单元格,该单元格也具有另一个邮件标签,应该发生相同的事情,但是邮件地址将是不同且动态的。
Q1) do i need to include only one method of mail for this to handle. Q1)我需要只包含一种邮件处理方法吗? Q2) If yes then how and if no then what is the procedure.
Q2)如果是,则如何,如果否,那么程序是什么。 i have used a second method for this and called this in cellForRow like
我为此使用了第二种方法,并在cellForRow中将其称为
-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
UITapGestureRecognizer *mgmtMail1LblGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(mail1LblTappedForCC:)];
[cell.managementMemberEmail addGestureRecognizer:mgmtMail1LblGesture];
and method. 和方法。
- (void)mail1LblTappedForCC:(id)sender
{
if ([MFMailComposeViewController canSendMail])
{
MFMailComposeViewController *mailer = [[MFMailComposeViewController alloc] init];
mailer.mailComposeDelegate = self;
[mailer setSubject:@""];
NSArray *toRecipients = [NSArray arrayWithObjects:objCCforManagement.managementMemberEmail.text, nil];
[mailer setToRecipients:toRecipients];
NSString *emailBody = @"";
[mailer setMessageBody:emailBody isHTML:NO];
mailer.navigationBar.barStyle = UIBarStyleBlackOpaque;
[self presentViewController:mailer animated:YES completion:nil];
}
else
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Failure"
message:@"Your device doesn't support the composer sheet"
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
}
}
where objCCforManagement is the object of custom class. 其中objCCforManagement是自定义类的对象。
How your recognizer will get the to recipient array from 您的识别器如何从中获取收件人数组
NSArray *toRecipients = [NSArray arrayWithObjects:objCCforManagement.managementMemberEmail.text, nil];
Use recognizer.view to get your label text or get value from objCCforManagement
on the basis of label.text. 使用
objCCforManagement
来获取标签文本或基于label.text从objCCforManagement
获取值。 Or particular tag set to label like label.tag=cellRowIndex
etc in cellForRow method 或在cellForRow方法中设置为标签的特定标签,例如
label.tag=cellRowIndex
等
Code ---- 代码----
cell.managementMemberEmail.tag=indexPath.row;
Your mail1LblTappedForCC method is unable to find which row value or objCCforManagement is to be inserted as recipient. 您的mail1LblTappedForCC方法找不到要作为接收者插入的行值或objCCforManagement。 thats why it is showing blank.
那就是为什么它显示空白。
Get your email on the basis of row tag by setting it to label. 通过将行标记设置为标签来获取电子邮件。
- (void)mail1LblTappedForCC:(UITapGestureRecognizer*)recognizer
{
if ([MFMailComposeViewController canSendMail])
{
UILabel *labelOnWhichItisClicked=(UILabel*)recognizer.view;
CustomCellForExhibitorDetailVC *cell=(CustomCellForExhibitorDetailVC*)[managementTableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:labelOnWhichItisClicked.tag inSection:0]];
NSLog(@"mail to is == %@",cell.managementMemberEmail.text);
MFMailComposeViewController *mailer = [[MFMailComposeViewController alloc] init];
mailer.mailComposeDelegate = self;
[mailer setSubject:@""];
NSArray *toRecipients =[NSArray arrayWithObjects:cell.managementMemberEmail.text,nil];
[mailer setToRecipients:toRecipients];
NSString *emailBody = @"";
[mailer setMessageBody:emailBody isHTML:NO];
mailer.navigationBar.barStyle = UIBarStyleBlackOpaque;
[self presentViewController:mailer animated:YES completion:nil];
}
else
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Failure"
message:@"Your device doesn't support the composer sheet"
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.