Domanda

Again forgive me if im not being clear, I have only started iOS dev yesterday.

So I have a application that is going to send information to specific email address. I have included a pickerview and populated it with an array of information, 5 or 6 different categories. What i want to do is to be able to change the recipient's of the email based on what category is selected in the pickerview.

So far I have but selectedRowInComponent doesn't seem to work.

- (IBAction)sendFinalItem:(UIButton *)sender {


NSLog(@"send button pressed");


if ([self.pickerView selectedRowInComponent:(0)])
{

    MFMailComposeViewController *mailcontroller = [[MFMailComposeViewController alloc] init];
    [mailcontroller setMailComposeDelegate:self]; 
    NSString *email =@"k_scully@hotmail.co.uk";

    NSArray *emailArray = [[NSArray alloc] initWithObjects:email, nil]; 
    [mailcontroller  setToRecipients:emailArray]; 
    [mailcontroller setSubject:@"[Urgent]Potential Job, iPhone snapped"];

    [self presentViewController:mailcontroller animated:YES completion:nil];
    [mailcontroller setMessageBody:notesTextView.text isHTML:NO];
}
È stato utile?

Soluzione

selectedRowInComponent: returns the index of the selection made by the user. You can use that value to check which e-mail address you need to use.

NSInteger selectedRow  = [self.pickerView selectedRowInComponent:0];
if (selectedRow == 0)
{
    // E-mail person 1
}
else if (selectedRow == 1)
{
    // E-mail person 2
}
// etc.
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top