-
Notifications
You must be signed in to change notification settings - Fork 0
/
UIViewController+ContactUs.m
84 lines (72 loc) · 2.5 KB
/
UIViewController+ContactUs.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
//
// UIViewController+ContactUs.m
// Creative Celebrations
//
// Created by MATTHEW S WOJNO on 2/22/15.
// Copyright (c) 2015 Matthew Wojno. All rights reserved.
//
#import "UIViewController+ContactUs.h"
#import <MessageUI/MessageUI.h>
@interface ContactUs()<MFMailComposeViewControllerDelegate>
@end
@implementation ContactUs
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (IBAction)makeCall:(id)sender {
NSString *phoneNumber = [@"tel://" stringByAppendingString:@"2488774714"];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:phoneNumber]];
}
-(IBAction)change:(id)sender{
NSString *place = @"Hello, ";
NSString *almost = [place stringByAppendingString:field.text];
label.text = [almost stringByAppendingString:@"! What can I help you with?"];
[label sizeToFit];
}
- (IBAction)showEmail:(id)sender {
// Email Subject
NSString *emailTitle = @"Enter Customer ID";
// Email Content
NSString *messageBody = @"";
// To address
NSArray *toRecipents = [NSArray arrayWithObject:@"[email protected]"];
MFMailComposeViewController *mc = [[MFMailComposeViewController alloc] init];
mc.mailComposeDelegate = self;
[mc setSubject:emailTitle];
[mc setMessageBody:messageBody isHTML:NO];
[mc setToRecipients:toRecipents];
// Present mail view controller on screen
[self presentViewController:mc animated:YES completion:NULL];
}
- (void) mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error
{
switch (result)
{
case MFMailComposeResultCancelled:
NSLog(@"Mail cancelled");
break;
case MFMailComposeResultSaved:
NSLog(@"Mail saved");
break;
case MFMailComposeResultSent:
NSLog(@"Mail sent");
break;
case MFMailComposeResultFailed:
NSLog(@"Mail sent failure: %@", [error localizedDescription]);
break;
default:
break;
}
// Close the Mail Interface
[self dismissViewControllerAnimated:YES completion:NULL];
}
@end