Permalink
Browse files

Added web view autoresizing.

  • Loading branch information...
1 parent a12b176 commit 9374371d6cf639c1057b298c69c7f4741a44e1fd @millenomi committed Jun 24, 2010
Showing with 10 additions and 1 deletion.
  1. +1 −0 L0WebViewController.h
  2. +9 −1 L0WebViewController.m
View
@@ -32,6 +32,7 @@
@property(readonly) CGRect webViewFrame; // The frame the web view will have on add. Default = self.view's bounds.
- (void) insertWebViewAsSubview; // Adds the web view to the hierarchy. The default is to add through addSubview: of self.view.
+@property(readonly) BOOL webViewAutoresizes; // if YES, the web view will be set to flexible width and height.
@end
View
@@ -48,6 +48,11 @@ - (CGRect) webViewFrame;
return self.view.bounds;
}
+- (BOOL) webViewAutoresizes;
+{
+ return YES;
+}
+
- (void) viewDidUnload;
{
self.webView = nil;
@@ -61,6 +66,9 @@ - (void) viewWillAppear:(BOOL) animated;
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]];
}
@@ -76,7 +84,7 @@ - (void) insertWebViewAsSubview;
- (void) viewDidDisappear:(BOOL) animated;
{
- [super viewWillAppear:animated];
+ [super viewDidDisappear:animated];
[self.webView removeFromSuperview];
self.webView = nil;
}

0 comments on commit 9374371

Please sign in to comment.