2013-08-13 2 views
0

내 문제는 레이블에있는 데이터가 웹 서비스에서오고 메일 상자를 두드려서 표시해야한다는 것입니다. 간단히 말해서 mailLabel입니다. 마찬가지로 같은보기에서 나는 다른 메일 레이블이 있고 동일한 일이 발생해야하는 사용자 지정 셀을 가지고 있지만 메일 주소는 동적이고 다를 것입니다.두 개의 다른 레이블에 대한 MFMailComposeViewController

Q1) 처리 할 메일이 하나만 포함되어야합니다. 질문 2) 그렇다면 어떻게하고 다음에 어떤 절차가 필요한가요? 제가

-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ 

     UITapGestureRecognizer *mgmtMail1LblGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(mail1LblTappedForCC:)]; 

     [cell.managementMemberEmail addGestureRecognizer:mgmtMail1LblGesture]; 

과 같은 방법이 cellForRow위한 두 번째 방법을 사용하고이 불렀다. objCCforManagement 사용자 정의 클래스의 객체이다

- (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]; 
    } 
} 

.

답변

0

당신의 인식이 레이블 텍스트를 가져 오거나 label.text에 기초 objCCforManagement에서 값을 가져

NSArray *toRecipients = [NSArray arrayWithObjects:objCCforManagement.managementMemberEmail.text, nil]; 

사용 recognizer.view에서받는 사람의 배열이 어떻게. 또는 특정 태그는

cell.managementMemberEmail.tag=indexPath.row; 

귀하의 mail1LblTappedForCC 방법은 행 값을 찾을 수 없습니다 또는 objCCforManagement받는 사람으로 삽입되는 ---- cellForRow 방법

코드에 label.tag=cellRowIndex 등 같은 레이블을 설정합니다. 그게 왜 비어있는거야.

레이블을 설정하여 행 태그를 기준으로 이메일을 보내십시오.

- (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]; 
    } 
} 
+0

감사합니다 !!! 스택에 최고의 교사 중 하나. –