forked from millenomi/muikit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
L0WebViewController.m
94 lines (71 loc) · 1.57 KB
/
L0WebViewController.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
85
86
87
88
89
90
91
92
93
94
//
// MvrWebViewController.m
// MuiKit
//
// Created by ∞ on 13/10/09.
// Copyright 2009 __MyCompanyName__. All rights reserved.
//
#if TARGET_OS_IPHONE
#import "L0WebViewController.h"
@interface L0WebViewController ()
@property(retain) UIWebView* webView;
@end
@implementation L0WebViewController
- (id) init;
{
return [self initWithNibName:nil bundle:nil];
}
@synthesize webView, initialURL;
- (void) dealloc;
{
self.webView = nil;
self.initialURL = nil;
[super dealloc];
}
- (void) loadView;
{
if (!self.nibName) {
CGRect r = [UIScreen mainScreen].bounds;
self.view = [[[UIView alloc] initWithFrame:r] autorelease];
[self viewDidLoad];
} else
[super loadView];
}
- (CGRect) webViewFrame;
{
return self.view.bounds;
}
- (BOOL) webViewAutoresizes;
{
return YES;
}
- (void) viewDidUnload;
{
self.webView = nil;
}
- (void) viewWillAppear:(BOOL) animated;
{
[super viewWillAppear:animated];
if (!self.webView) {
self.webView = [[[UIWebView alloc] initWithFrame:self.webViewFrame] autorelease];
self.webView.delegate = self;
if (self.webViewAutoresizes)
self.webView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
if (self.initialURL)
[self.webView loadRequest:[NSURLRequest requestWithURL:self.initialURL]];
}
[self insertWebViewAsSubview];
}
- (void) insertWebViewAsSubview;
{
if (!self.webView.superview)
[self.view addSubview:self.webView];
}
- (void) viewDidDisappear:(BOOL) animated;
{
[super viewDidDisappear:animated];
[self.webView removeFromSuperview];
self.webView = nil;
}
@end
#endif