1 | |
---|
2 | |
---|
3 | |
---|
4 | |
---|
5 | |
---|
6 | |
---|
7 | |
---|
8 | |
---|
9 | |
---|
10 | |
---|
11 | |
---|
12 | #import "SupportViewController.h" |
---|
13 | |
---|
14 | @implementation SupportViewController |
---|
15 | |
---|
16 | @synthesize webView, retryButton, status; |
---|
17 | |
---|
18 | - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil |
---|
19 | { |
---|
20 | self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; |
---|
21 | if (self) { |
---|
22 | |
---|
23 | } |
---|
24 | return self; |
---|
25 | } |
---|
26 | |
---|
27 | - (void)viewDidLoad |
---|
28 | { |
---|
29 | [super viewDidLoad]; |
---|
30 | [self loadSupportSite]; |
---|
31 | } |
---|
32 | |
---|
33 | |
---|
34 | #define BASEURL [NSURL fileURLWithPath:[[NSBundle mainBundle] bundlePath]] |
---|
35 | - (void) loadSupportSite |
---|
36 | { |
---|
37 | |
---|
38 | |
---|
39 | |
---|
40 | |
---|
41 | NSString *urlAddress = [[NSBundle mainBundle] pathForResource:@"support" ofType:@"html"]; |
---|
42 | |
---|
43 | NSURL *url = [NSURL fileURLWithPath:urlAddress]; |
---|
44 | NSURLRequest *requestObj = [NSURLRequest requestWithURL:url]; |
---|
45 | [webView loadRequest:requestObj]; |
---|
46 | |
---|
47 | |
---|
48 | } |
---|
49 | |
---|
50 | |
---|
51 | -(BOOL) webView:(UIWebView *)inWeb shouldStartLoadWithRequest:(NSURLRequest *)inRequest navigationType:(UIWebViewNavigationType)inType { |
---|
52 | |
---|
53 | |
---|
54 | |
---|
55 | |
---|
56 | |
---|
57 | |
---|
58 | |
---|
59 | |
---|
60 | |
---|
61 | |
---|
62 | if ( inType == UIWebViewNavigationTypeLinkClicked ) { |
---|
63 | [[UIApplication sharedApplication] openURL:[inRequest URL]]; |
---|
64 | return NO; |
---|
65 | } |
---|
66 | |
---|
67 | |
---|
68 | |
---|
69 | |
---|
70 | |
---|
71 | |
---|
72 | |
---|
73 | |
---|
74 | |
---|
75 | |
---|
76 | |
---|
77 | |
---|
78 | |
---|
79 | return YES; |
---|
80 | |
---|
81 | } |
---|
82 | |
---|
83 | |
---|
84 | |
---|
85 | #pragma mark UIWebViewDelegate methods |
---|
86 | |
---|
87 | - (void)webViewDidFinishLoad:(UIWebView *)webView |
---|
88 | { |
---|
89 | retryButton.hidden = YES; |
---|
90 | status.hidden = YES; |
---|
91 | } |
---|
92 | |
---|
93 | - (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error |
---|
94 | { |
---|
95 | UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Not Connected" message:@"Unable to view support since you have no internet connection" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil]; |
---|
96 | [alert show]; |
---|
97 | retryButton.hidden = NO; |
---|
98 | status.hidden = NO; |
---|
99 | status.text = @"Unable to load support site"; |
---|
100 | } |
---|
101 | |
---|
102 | #pragma mark button press methods |
---|
103 | |
---|
104 | - (IBAction) retryButtonPressed:(id) sender { |
---|
105 | retryButton.hidden = YES; |
---|
106 | status.text = @"Loading support website..."; |
---|
107 | [self loadSupportSite]; |
---|
108 | } |
---|
109 | |
---|
110 | @end |
---|