Skip to content

Commit

Permalink
Add back/forward navigation and "open in safari" button to the modal …
Browse files Browse the repository at this point in the history
…UIWebView
  • Loading branch information
Sebastian Steinmetz committed Feb 27, 2012
1 parent 85e1556 commit 9f32e4d
Show file tree
Hide file tree
Showing 6 changed files with 138 additions and 10 deletions.
8 changes: 8 additions & 0 deletions Baker.xcodeproj/project.pbxproj
Expand Up @@ -15,6 +15,8 @@
578A4F2114B1AF570054CD50 /* MessageUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 578A4F2014B1AF570054CD50 /* MessageUI.framework */; };
84E7F05614F63CC8005B1929 /* ModalViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 84E7F05514F63CC8005B1929 /* ModalViewController.xib */; };
84E7F05A14F63CDF005B1929 /* ModalViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 84E7F05914F63CDF005B1929 /* ModalViewController.m */; };
84ED947314FC389000538EE5 /* forward.png in Resources */ = {isa = PBXBuildFile; fileRef = 84ED947214FC389000538EE5 /* forward.png */; };
84ED947614FC389D00538EE5 /* back.png in Resources */ = {isa = PBXBuildFile; fileRef = 84ED947514FC389D00538EE5 /* back.png */; };
9F123763129F133700B7E8C8 /* Downloader.m in Sources */ = {isa = PBXBuildFile; fileRef = 9F123762129F133700B7E8C8 /* Downloader.m */; };
9F242EDA11FB344D00641757 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9F242ED911FB344D00641757 /* QuartzCore.framework */; };
9F4F07F411F8DE8200375A8C /* RootViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 9F4F07F211F8DE8200375A8C /* RootViewController.m */; };
Expand Down Expand Up @@ -76,6 +78,8 @@
84E7F05514F63CC8005B1929 /* ModalViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = ModalViewController.xib; sourceTree = "<group>"; };
84E7F05814F63CDF005B1929 /* ModalViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ModalViewController.h; sourceTree = "<group>"; };
84E7F05914F63CDF005B1929 /* ModalViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ModalViewController.m; sourceTree = "<group>"; };
84ED947214FC389000538EE5 /* forward.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = forward.png; sourceTree = "<group>"; };
84ED947514FC389D00538EE5 /* back.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = back.png; sourceTree = "<group>"; };
8D1107310486CEB800E47090 /* Baker-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "Baker-Info.plist"; plistStructureDefinitionIdentifier = "com.apple.xcode.plist.structure-definition.iphone.info-plist"; sourceTree = "<group>"; };
9F123761129F133700B7E8C8 /* Downloader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Downloader.h; sourceTree = "<group>"; };
9F123762129F133700B7E8C8 /* Downloader.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Downloader.m; sourceTree = "<group>"; };
Expand Down Expand Up @@ -212,6 +216,8 @@
29B97317FDCFA39411CA2CEA /* Resources */ = {
isa = PBXGroup;
children = (
84ED947514FC389D00538EE5 /* back.png */,
84ED947214FC389000538EE5 /* forward.png */,
84E7F05514F63CC8005B1929 /* ModalViewController.xib */,
BFEC41E51309D9CA00628DF3 /* ios-icon-iphone57.png */,
BFEC41E71309D9CE00628DF3 /* ios-icon-iphone114.png */,
Expand Down Expand Up @@ -385,6 +391,8 @@
BFEC41E61309D9CA00628DF3 /* ios-icon-iphone57.png in Resources */,
BFEC41E81309D9CE00628DF3 /* ios-icon-iphone114.png in Resources */,
84E7F05614F63CC8005B1929 /* ModalViewController.xib in Resources */,
84ED947314FC389000538EE5 /* forward.png in Resources */,
84ED947614FC389D00538EE5 /* back.png in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
5 changes: 5 additions & 0 deletions Classes/ModalViewController.h
Expand Up @@ -39,9 +39,14 @@

@property (nonatomic, assign) id <modalWebViewDelegate> delegate;
@property (nonatomic, assign) IBOutlet UIWebView *webView;
@property (nonatomic, assign) IBOutlet UIBarButtonItem *backButton;
@property (nonatomic, assign) IBOutlet UIBarButtonItem *forwardButton;

- (id)initWithUrl:(NSURL *)url;
- (IBAction)dismissAction:(id)sender;
- (IBAction)goBack:(id)sender;
- (IBAction)goForward:(id)sender;
- (IBAction)openInSafari:(id)sender;

@end

Expand Down
24 changes: 21 additions & 3 deletions Classes/ModalViewController.m
Expand Up @@ -32,7 +32,7 @@
#import "ModalViewController.h"

@implementation ModalViewController
@synthesize delegate, webView;
@synthesize delegate, webView, backButton, forwardButton;

- (id)initWithUrl:(NSURL *)url {
myUrl = url;
Expand All @@ -43,8 +43,6 @@ - (id)initWithUrl:(NSURL *)url {
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
if (!(self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]))
return nil;

self.title = NSLocalizedString(@"ModalTitle", @"");

return self;
}
Expand All @@ -69,8 +67,28 @@ - (void)viewDidLoad {
- (void)viewDidUnload {
}

#pragma mark - UIWebView delegate methods
- (void)webViewDidFinishLoad:(UIWebView *)webView1 {
backButton.enabled = [webView1 canGoBack];
forwardButton.enabled = [webView1 canGoForward];
}

#pragma mark - Interface Builder Actions

- (IBAction)dismissAction:(id)sender {
[[self delegate] done:self];
}

- (IBAction)goBack:(id)sender {
[webView goBack];
}

- (IBAction)goForward:(id)sender {
[webView goForward];
}

- (IBAction)openInSafari:(id)sender {
[[UIApplication sharedApplication] openURL:webView.request.URL];
}

@end
111 changes: 104 additions & 7 deletions ModalViewController.xib
Expand Up @@ -3,12 +3,12 @@
<data>
<int key="IBDocument.SystemTarget">1280</int>
<string key="IBDocument.SystemVersion">11D50</string>
<string key="IBDocument.InterfaceBuilderVersion">1938</string>
<string key="IBDocument.InterfaceBuilderVersion">2177</string>
<string key="IBDocument.AppKitVersion">1138.32</string>
<string key="IBDocument.HIToolboxVersion">568.00</string>
<object class="NSMutableDictionary" key="IBDocument.PluginVersions">
<string key="NS.key.0">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="NS.object.0">933</string>
<string key="NS.object.0">1173</string>
</object>
<array key="IBDocument.IntegratedClassDependencies">
<string>IBUIWebView</string>
Expand Down Expand Up @@ -53,21 +53,44 @@
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
<int key="IBUIBarStyle">1</int>
<array class="NSMutableArray" key="IBUIItems">
<object class="IBUIBarButtonItem" id="280998457">
<object class="NSCustomResource" key="IBUIImage">
<string key="NSClassName">NSImage</string>
<string key="NSResourceName">back.png</string>
</object>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
<reference key="IBUIToolbar" ref="954247977"/>
</object>
<object class="IBUIBarButtonItem" id="227363092">
<object class="NSCustomResource" key="IBUIImage">
<string key="NSClassName">NSImage</string>
<string key="NSResourceName">forward.png</string>
</object>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
<reference key="IBUIToolbar" ref="954247977"/>
</object>
<object class="IBUIBarButtonItem" id="1022859311">
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
<reference key="IBUIToolbar" ref="954247977"/>
<int key="IBUISystemItemIdentifier">5</int>
</object>
<object class="IBUIBarButtonItem" id="321803189">
<string key="IBUITitle">back</string>
<object class="IBUIBarButtonItem" id="467278003">
<string key="IBUITitle">open in Safari</string>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
<int key="IBUIStyle">1</int>
<reference key="IBUIToolbar" ref="954247977"/>
<object class="NSColor" key="IBUITintColor">
<object class="NSColor" key="IBUITintColor" id="617107956">
<int key="NSColorSpace">3</int>
<bytes key="NSWhite">MAA</bytes>
</object>
</object>
<object class="IBUIBarButtonItem" id="321803189">
<string key="IBUITitle">close</string>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
<int key="IBUIStyle">2</int>
<reference key="IBUIToolbar" ref="954247977"/>
<reference key="IBUITintColor" ref="617107956"/>
</object>
</array>
<object class="NSColor" key="IBUITintColor">
<int key="NSColorSpace">1</int>
Expand All @@ -79,6 +102,7 @@
<int key="NSvFlags">274</int>
<string key="NSFrame">{{0, 44}, {320, 416}}</string>
<reference key="NSSuperview" ref="518503493"/>
<reference key="NSNextKeyView"/>
<string key="NSReuseIdentifierKey">_NS:693</string>
<object class="NSColor" key="IBUIBackgroundColor">
<int key="NSColorSpace">1</int>
Expand Down Expand Up @@ -119,6 +143,30 @@
</object>
<int key="connectionID">31</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">backButton</string>
<reference key="source" ref="841351856"/>
<reference key="destination" ref="280998457"/>
</object>
<int key="connectionID">48</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">forwardButton</string>
<reference key="source" ref="841351856"/>
<reference key="destination" ref="227363092"/>
</object>
<int key="connectionID">49</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">delegate</string>
<reference key="source" ref="913829866"/>
<reference key="destination" ref="841351856"/>
</object>
<int key="connectionID">50</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchEventConnection" key="connection">
<string key="label">dismissAction:</string>
Expand All @@ -127,6 +175,30 @@
</object>
<int key="connectionID">37</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchEventConnection" key="connection">
<string key="label">goBack:</string>
<reference key="source" ref="280998457"/>
<reference key="destination" ref="841351856"/>
</object>
<int key="connectionID">46</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchEventConnection" key="connection">
<string key="label">goForward:</string>
<reference key="source" ref="227363092"/>
<reference key="destination" ref="841351856"/>
</object>
<int key="connectionID">45</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchEventConnection" key="connection">
<string key="label">openInSafari:</string>
<reference key="source" ref="467278003"/>
<reference key="destination" ref="841351856"/>
</object>
<int key="connectionID">47</int>
</object>
</array>
<object class="IBMutableOrderedSet" key="objectRecords">
<array key="orderedObjects">
Expand Down Expand Up @@ -167,6 +239,9 @@
<array class="NSMutableArray" key="children">
<reference ref="321803189"/>
<reference ref="1022859311"/>
<reference ref="280998457"/>
<reference ref="227363092"/>
<reference ref="467278003"/>
</array>
<reference key="parent" ref="518503493"/>
</object>
Expand All @@ -180,6 +255,21 @@
<reference key="object" ref="1022859311"/>
<reference key="parent" ref="954247977"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">38</int>
<reference key="object" ref="280998457"/>
<reference key="parent" ref="954247977"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">40</int>
<reference key="object" ref="227363092"/>
<reference key="parent" ref="954247977"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">42</int>
<reference key="object" ref="467278003"/>
<reference key="parent" ref="954247977"/>
</object>
</array>
</object>
<dictionary class="NSMutableDictionary" key="flattenedProperties">
Expand All @@ -192,18 +282,25 @@
<string key="33.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="34.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="35.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="38.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="40.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="42.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
</dictionary>
<dictionary class="NSMutableDictionary" key="unlocalizedProperties"/>
<nil key="activeLocalization"/>
<dictionary class="NSMutableDictionary" key="localizations"/>
<nil key="sourceID"/>
<int key="maxID">37</int>
<int key="maxID">50</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes"/>
<int key="IBDocument.localizationMode">0</int>
<string key="IBDocument.TargetRuntimeIdentifier">IBCocoaTouchFramework</string>
<bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool>
<int key="IBDocument.defaultPropertyAccessControl">3</int>
<string key="IBCocoaTouchPluginVersion">933</string>
<dictionary class="NSMutableDictionary" key="IBDocument.LastKnownImageSizes">
<string key="back.png">{16, 16}</string>
<string key="forward.png">{16, 16}</string>
</dictionary>
<string key="IBCocoaTouchPluginVersion">1173</string>
</data>
</archive>
Binary file added back.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added forward.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 9f32e4d

Please sign in to comment.