我的问题是我有一个带标签的视图,其中,标签上的数据来自网络服务,点击它的邮箱应该出现。简而言之,它是一个mailLabel。 同样在同一个视图中我有一个自定义单元格,它也有另一个邮件标签,同样的事情应该发生,但邮件地址将是不同的和动态的。
Q1)我是否只需要包含一种邮件方法来处理。 Q2)如果是,那么如何以及如果没有那么程序是什么。 我已经使用了第二种方法,并在cellForRow中调用它,如
-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
UITapGestureRecognizer *mgmtMail1LblGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(mail1LblTappedForCC:)];
[cell.managementMemberEmail addGestureRecognizer:mgmtMail1LblGesture];
和方法。
- (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];
}
}
,其中 objCCforManagement是自定义类的对象。
答案 0 :(得分:0)
识别器如何从
获取收件人数组NSArray *toRecipients = [NSArray arrayWithObjects:objCCforManagement.managementMemberEmail.text, nil];
使用recognizer.view获取标签文本或根据label.text从objCCforManagement
获取值。或者在cellForRow方法
label.tag=cellRowIndex
等标签
代码----
cell.managementMemberEmail.tag=indexPath.row;
您的mail1LblTappedForCC方法无法找到要将哪个行值或objCCforManagement作为收件人插入。这就是为什么它显示空白。
通过将其设置为标签来获取基于行标记的电子邮件。
- (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];
}
}