This repository has been archived by the owner on May 8, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
DCTConnectionViewController.m
61 lines (43 loc) · 1.58 KB
/
DCTConnectionViewController.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
//
// DCTConnectionViewController.m
//
//
// Created by Daniel Tull on 11.11.2011.
// Copyright (c) 2011 Daniel Tull. All rights reserved.
//
#import "DCTConnectionViewController.h"
#import "DCTConnectionControllerDisplay.h"
@implementation DCTConnectionViewController
@synthesize connectionController;
@synthesize webView;
@synthesize navigationBar;
@synthesize completionBlock;
#pragma mark - UIViewController
- (void)viewDidLoad {
[super viewDidLoad];
[self.webView loadRequest:self.connectionController.URLRequest];
self.navigationBar.topItem.title = self.title;
}
- (void)setTitle:(NSString *)title {
[super setTitle:title];
self.navigationBar.topItem.title = title;
}
- (void)viewDidDisappear:(BOOL)animated {
[super viewDidDisappear:animated];
}
#pragma mark - DCTConnectionControllerDisplay
- (void)dismissConnectionControllerDisplay {
if (self.completionBlock) self.completionBlock();
}
#pragma mark - UIWebViewDelegate
- (void)webViewDidFinishLoad:(UIWebView *)wv {
if (!self.title || [self.title isEqualToString:@""])
self.title = [wv stringByEvaluatingJavaScriptFromString:@"document.title"];
}
- (BOOL)webView:(UIWebView *)webView
shouldStartLoadWithRequest:(NSURLRequest *)request
navigationType:(UIWebViewNavigationType)navigationType {
NSAssert([self.connectionController conformsToProtocol:@protocol(DCTDisplayableConnectionController)], @"Connection controller %@ should adhere to the DCTConnectionControllerDisplay protocol.", self.connectionController);
return [self.connectionController connectionControllerDisplay:self shouldLoadURLRequest:request];
}
@end