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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
//
//  ContactUsViewController.h
//  Assaultive
//
//  Created by Jack on 04.08.12.
//  Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//

#import <UIKit/UIKit.h>
#import "webSiteViewController.h"
#import <MediaPlayer/MediaPlayer.h>
#import <MessageUI/MessageUI.h>
#import <MessageUI/MFMailComposeViewController.h>


@interface ContactUsViewController : UIViewController <UITableViewDelegate, UITableViewDataSource, MFMailComposeViewControllerDelegate > {
    
    NSMutableArray *contactOptionsArray;
    NSMutableArray *detailContactArray;
    NSMutableArray *cellIconNames;
}
@property (nonatomic, retain) NSArray *cellIconNames;
-(void)facebook;
-(void)twitter;
-(void)mail;
-(void)youtube;

@end


Implementation


//
//  ContactUsViewController.m
//  Assaultive
//
//  Created by Jack Stean on 04.08.12.
//  Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//

#import "ContactUsViewController.h"

int counterSecond;

@interface ContactUsViewController ()

@end

@implementation ContactUsViewController
@synthesize cellIconNames;

-(void)visitWebSite {
    
    webSiteViewController *webController = [[webSiteViewController alloc] initWithNibName:@"webSiteViewController" bundle:nil];
    
    [self presentModalViewController:webController animated:YES];
    
}



-(void)youtube {
    
    NSString *stringURL = @"http://www.youtube.com/watch?v=ClLieGrqoZ0&feature=g-all-u";
    NSURL *url = [NSURL URLWithString:stringURL];
    [[UIApplication sharedApplication] openURL:url];
        
}


//fb://profile/249471155162505

-(void)facebook {
    
    if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"fb://"]]) {
        NSURL *url = [NSURL URLWithString:@"fb://profile/249471155162505"];
        [[UIApplication sharedApplication] openURL:url];
    }
    else {
        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.facebook.com/Assaultive"]];  
    }
    
}

//twitter://user?id=222026157

-(void)twitter {
    
    if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"twitter://"]]) {
        NSURL *url = [NSURL URLWithString:@"twitter://user?id=222026157"];
        [[UIApplication sharedApplication] openURL:url];
    }
    else {
        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://twitter.com/assaultive"]];  
    }
    
}

-(void)mail {
    
       NSString *mailstring = [NSString stringWithFormat:@"mailto:[email protected]?subject=Question/Intro&body=Hallo,Assautlive"];
       [[UIApplication sharedApplication] openURL:[NSURL URLWithString:mailstring]];
    

    
   /* MFMailComposeViewController *controller =
    [[MFMailComposeViewController alloc] init]; 
    controller.mailComposeDelegate = self;
    [controller setToRecipients:[NSArray arrayWithObjects:@"Assaultive<[email protected]>", nil]];
    [controller setSubject:@"Questions/Intro"];
    [controller setMessageBody:@"Hello Assaultive" isHTML:NO];
    [self presentModalViewController:controller animated:YES];
    [controller release];
    */
}

/*- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error 
{   
    // Notifies users about errors associated with the interface
    switch (result)
    {
        case MFMailComposeResultCancelled:
            NSLog(@"Result: canceled");
            [self dismissModalViewControllerAnimated:YES];
            break;
        case MFMailComposeResultSaved:
             NSLog(@"Result: saved");
            [self dismissModalViewControllerAnimated:YES];
            break;
        case MFMailComposeResultSent:
            NSLog(@"Result: sent");
            UIAlertView *sendMail = [[UIAlertView alloc] initWithTitle:@"Sending Message..." message:@"Sending Message to Assaultive." delegate:nil cancelButtonTitle:@"Okay" otherButtonTitles:nil];
            [sendMail show];
            [sendMail release];
            [self dismissModalViewControllerAnimated:YES];
            break;
        case MFMailComposeResultFailed:
            NSLog(@"Result: failed");
            [self dismissModalViewControllerAnimated:YES];
            break;
        default:
            NSLog(@"Result: not sent");
            [self dismissModalViewControllerAnimated:YES];
            break;
    }
    [self dismissModalViewControllerAnimated:YES];
}

*/



-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    
    
    return [contactOptionsArray count];
}


-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    UITableViewCell *cell;
    cell = [UITableViewCell alloc];
    cell = [cell initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:nil];
    cell = [cell autorelease];
    
    NSString *cellIconName = [[self cellIconNames] objectAtIndex:[indexPath row]];
    UIImage *cellIcon = [UIImage imageNamed:cellIconName];
    [[cell imageView] setImage:cellIcon];
    
    cell.detailTextLabel.text = [detailContactArray objectAtIndex:indexPath.row];
    cell.textLabel.text = [contactOptionsArray objectAtIndex:indexPath.row];
    
    return cell;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    
    if (indexPath.row == 0) {
        [self facebook];
    }
    if (indexPath.row == 1) {
        [self twitter];
    }
    if (indexPath.row == 2) {
        [self youtube];
    }
    if (indexPath.row == 3) {
        [self mail];
    }
    if (indexPath.row == 4) {
        [self visitWebSite];
    }
}

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        self.title = NSLocalizedString(@"Contact Us", @"Third");
        self.tabBarItem.image = [UIImage imageNamed:@"contactustab"];
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    [self setCellIconNames:[NSArray arrayWithObjects:@"facebook.png", @"twitter.png", @"youtube.png", @"contact.png", @"website.png", nil]];
    
    contactOptionsArray = [[NSMutableArray alloc] initWithObjects:@"Facebook", @"Twitter", @"Youtube", @"Email", @"Website", nil];
    
    detailContactArray = [[NSMutableArray alloc] initWithObjects:@"http://www.facebook.com/Assaultive", @"http://twitter.com/assaultive", @"http://www.youtube.com/user/Assaultive", @"[email protected]", @"http://assaultive.tk", nil];
    
    UINavigationBar *navBar = [[UINavigationBar alloc] initWithFrame:CGRectMake(0, 0, 320, 40)];
    UINavigationItem *item = [[UINavigationItem alloc] initWithTitle:@"Contact Us"];
    [navBar pushNavigationItem:item animated:YES];
    navBar.topItem.title = @"Contact Us";
    navBar.barStyle = UIStatusBarStyleBlackOpaque;
    [self.view addSubview:navBar];
    
    UIImageView *imgViewBG = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 320, 1800)];
    imgViewBG.image = [UIImage imageNamed:@"bg2.png"];
    [self.view addSubview:imgViewBG];
    
    UITableView *contactOptionTable = [[UITableView alloc] initWithFrame:CGRectMake(0, 40, 320, 440) style:UITableViewStyleGrouped];
    contactOptionTable.backgroundView = imgViewBG;
    contactOptionTable.delegate = self;
    contactOptionTable.dataSource = self;
    [self.view addSubview:contactOptionTable];
    
    UIImageView *imgView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 225, 320, 150)];
    imgView.image = [UIImage imageNamed:@"assaultive.png"];
    [contactOptionTable insertSubview:imgView belowSubview:self.view];
    
    
}

- (void)viewDidUnload
{
    [super viewDidUnload];
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

@end