Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Adding delegate option to dismiss the web browser.

  • Loading branch information...
commit 5344f538abe32d011bb5cc4e95d306e3cc4d5d57 1 parent fda2f66
@pk authored
View
20 PKToolbox/Sources/UIKit/PKWebBrowserController.h
@@ -8,32 +8,26 @@
#import <UIKit/UIKit.h>
+@class PKWebBrowserController;
-@interface PKWebBrowserController : UIViewController <UIWebViewDelegate> {
-@private
- NSString *loadingTitle_;
- UINavigationBar *navigationBar_;
- UIToolbar *toolBar_;
- UIWebView *webView_;
+@protocol PKWebBrowserControllerDelegate <NSObject>
+- (void)needDismissWebBrowser:(PKWebBrowserController *)aWebBrowser;
+@end
- UIBarButtonItem *forwardBarButton_;
- UIBarButtonItem *backBarButton_;
- BOOL presentedModally_;
-}
+@interface PKWebBrowserController : UIViewController <UIWebViewDelegate>
@property (nonatomic, retain, readwrite) UINavigationBar *navigationBar;
@property (nonatomic, retain, readwrite) UIToolbar *toolBar;
@property (nonatomic, retain, readwrite) UIWebView *webView;
@property (nonatomic, copy, readwrite) NSString *loadingTitle;
+@property (nonatomic, assign, readwrite) id<PKWebBrowserControllerDelegate> delegate;
-@property (nonatomic, assign, readwrite, getter=isPresentedModally) BOOL presentedModally;
-
+@property (nonatomic, assign, readwrite, getter=isPresentedModally) BOOL presentedModally;
@property (nonatomic, assign, readwrite, getter=isBackButtonHidden) BOOL backButtonHidden;
@property (nonatomic, assign, readwrite, getter=isForwardButtonHidden) BOOL forwardButtonHidden;
@property (nonatomic, assign, readwrite, getter=isRefreshButtonHidden) BOOL refreshButtonHidden;
-
- (void)loadRequest:(NSURLRequest *)aRequest;
- (void)loadURL:(NSURL *)aURL;
- (void)loadURLString:(NSString *)aURL;
View
23 PKToolbox/Sources/UIKit/PKWebBrowserController.m
@@ -23,10 +23,11 @@ @implementation PKWebBrowserController
@synthesize backBarButton = backBarButton_;
@synthesize forwardBarButton = forwardBarButton_;
@synthesize loadingTitle = loadingTitle_;
-@synthesize navigationBar = navBar_;
+@synthesize navigationBar = navigationBar_;
@synthesize presentedModally = presentedModally_;
@synthesize toolBar = toolBar_;
@synthesize webView = webView_;
+@synthesize delegate = delegate_;
@synthesize backButtonHidden = backButtonHidden_;
@synthesize forwardButtonHidden = forwardButtonHidden_;
@@ -48,15 +49,17 @@ - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
}
- (void)dealloc {
+ self.delegate = nil;
+
[backBarButton_ release];
[forwardBarButton_ release];
[loadingTitle_ release];
[navigationBar_ release];
[toolBar_ release];
-
+
self.webView.delegate = nil;
- [webView_ release];
-
+ [webView_ release];
+
[super dealloc];
}
@@ -163,7 +166,7 @@ - (void)viewDidUnload {
self.toolBar = nil;
self.backBarButton = nil;
self.forwardBarButton = nil;
-
+
self.webView.delegate = nil;
self.webView = nil;
}
@@ -216,7 +219,15 @@ - (IBAction)refresh {
- (IBAction)close {
[self.webView stopLoading];
- [self dismissModalViewControllerAnimated:YES];
+
+ if (self.delegate && [self.delegate respondsToSelector:@selector(needDismissWebBrowser:)]) {
+ [self.delegate needDismissWebBrowser:self];
+ return;
+ }
+
+ if (self.presentedModally) {
+ [self dismissModalViewControllerAnimated:YES];
+ }
}
Please sign in to comment.
Something went wrong with that request. Please try again.