Frage

Hi everyoneI need some direction on how to go about accomplishing a task. I have a app with 5 tab bar items I need to program one of the tabs to call a modal dialog box that has three options. 1. Cancel 2. Call Us 3. Email Us. if the user pushes call us the device should start calling our 800 number if they press email us then it should open the email client and put our sales or support team automatically in the "to:" section. Please provide me with some direction or perhaps a tutorial on how to something like this. Thank you for your help.

War es hilfreich?

Lösung

I have added these tasks in a different view using two UIButtons. if you come up with a way to do a popOver please let me know. If not I will go with what I have. Thank you. The code I used for email and call (both can be found by doing a SO search) in case anyone else looks in on this thread are as follows:

EMAIL

-(IBAction)emailUs:(id)sender
{
    if ([MFMailComposeViewController canSendMail])
    {
        MFMailComposeViewController *mailViewcontroller = [[MFMailComposeViewController alloc]init];
        mailViewcontroller.mailComposeDelegate = self;
        [mailViewcontroller setToRecipients:[NSArray arrayWithObjects:@"CustomerService@laserpros.com", nil]];
        [mailViewcontroller setTitle:@"Email Us"];
        [mailViewcontroller setSubject:@"Email Us"];
        [mailViewcontroller setMessageBody:@"Your message goes here" isHTML:NO];
        [self presentViewController:mailViewcontroller animated:YES completion:nil];

    }
    else
    {
        NSLog(@"Device is unable to send email in its current state.");
    }
}
-(void)mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error
{
    [self dismissViewControllerAnimated:YES completion:nil];
}

CALL

-(IBAction)callUs:(id)sender
{
    NSURL *phoneNumber = [NSURL URLWithString:@"telprompt://18885585277"];
    [[UIApplication sharedApplication] openURL:phoneNumber];

}
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top