Skip to content

Commit 361c245

Browse files
fix a couple runtime warnings, simplify code.
1 parent 65e542d commit 361c245

7 files changed

+258
-37
lines changed

Classes/FlatWebView.m

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -21,32 +21,21 @@
2121

2222
#import "FlatWebView.h"
2323

24-
@interface FlatWebView ()
25-
- (void)hideImageViewsIn:(UIView*)view;
26-
@end
27-
2824
@implementation FlatWebView
2925

3026
- (void)layoutSubviews
3127
{
3228
[super layoutSubviews];
33-
34-
[self hideImageViewsIn:self];
35-
}
36-
37-
- (void)hideImageViewsIn:(UIView*)view
38-
{
39-
for (UIView *v in view.subviews)
40-
{
41-
if ([v isKindOfClass:[UIImageView class]])
42-
{
43-
v.hidden = YES;
44-
}
45-
else
46-
{
47-
[self hideImageViewsIn:v];
48-
}
49-
}
29+
30+
id scrollview = [self.subviews objectAtIndex:0];
31+
32+
for (UIView *subview in [scrollview subviews])
33+
{
34+
if ([subview isKindOfClass:[UIImageView class]])
35+
{
36+
subview.hidden = YES;
37+
}
38+
}
5039
}
5140

5241
@end

Classes/FlatWebViewAppDelegate.h

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,10 @@
2121

2222
#import <UIKit/UIKit.h>
2323

24-
@class FlatWebView;
24+
@class RootViewController;
2525

2626
@interface FlatWebViewAppDelegate : NSObject <UIApplicationDelegate>
27-
{
28-
UIWindow *window;
29-
FlatWebView *webView;
30-
}
31-
@property (nonatomic, retain) IBOutlet UIWindow *window;
27+
@property(strong, nonatomic) RootViewController *rootViewController;
28+
@property(strong, nonatomic) IBOutlet UIWindow *window;
3229
@end
3330

Classes/FlatWebViewAppDelegate.m

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,17 @@
2121

2222

2323
#import "FlatWebViewAppDelegate.h"
24-
#import "FlatWebView.h"
24+
#import "RootViewController.h"
2525

2626
@implementation FlatWebViewAppDelegate
27-
28-
@synthesize window;
27+
@synthesize rootViewController = _rootViewController;
28+
@synthesize window = _window;
2929

3030
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
31-
{
32-
webView = [[FlatWebView alloc] initWithFrame:CGRectMake(0, 20, 320, 460)];
33-
webView.scalesPageToFit = YES;
34-
webView.backgroundColor = [UIColor colorWithRed:(241.0/255.0) green:(241.0/255.0) blue:(241.0/255.0) alpha:1.0];
35-
[webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://cocoacontrols.com"]]];
36-
37-
[self.window addSubview:webView];
31+
{
32+
self.rootViewController = [[RootViewController alloc] initWithNibName:@"RootViewController" bundle:nil];
33+
34+
self.window.rootViewController = self.rootViewController;
3835
[self.window makeKeyAndVisible];
3936

4037
return YES;

Classes/RootViewController.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//
2+
// RootViewController.h
3+
// FlatWebView
4+
//
5+
// Created by Aaron Brethorst on 7/4/12.
6+
// Copyright (c) 2012 Structlab LLC. All rights reserved.
7+
//
8+
9+
#import <UIKit/UIKit.h>
10+
11+
@class FlatWebView;
12+
13+
@interface RootViewController : UIViewController
14+
@property(strong,nonatomic) IBOutlet FlatWebView *webView;
15+
@end

Classes/RootViewController.m

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
//
2+
// RootViewController.m
3+
// FlatWebView
4+
//
5+
// Created by Aaron Brethorst on 7/4/12.
6+
// Copyright (c) 2012 Structlab LLC. All rights reserved.
7+
//
8+
9+
#import "RootViewController.h"
10+
#import "FlatWebView.h"
11+
12+
@implementation RootViewController
13+
@synthesize webView = _webView;
14+
15+
- (void)viewDidLoad
16+
{
17+
[super viewDidLoad];
18+
19+
self.webView.backgroundColor = [UIColor colorWithRed:(241.0/255.0) green:(241.0/255.0) blue:(241.0/255.0) alpha:1.0];
20+
[self.webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://cocoacontrols.com"]]];
21+
}
22+
23+
- (void)viewDidUnload
24+
{
25+
[super viewDidUnload];
26+
// Release any retained subviews of the main view.
27+
// e.g. self.myOutlet = nil;
28+
}
29+
30+
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
31+
{
32+
return YES;
33+
}
34+
35+
@end

Classes/RootViewController.xib

Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<archive type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="8.00">
3+
<data>
4+
<int key="IBDocument.SystemTarget">1296</int>
5+
<string key="IBDocument.SystemVersion">11E2705</string>
6+
<string key="IBDocument.InterfaceBuilderVersion">2182</string>
7+
<string key="IBDocument.AppKitVersion">1138.47</string>
8+
<string key="IBDocument.HIToolboxVersion">569.00</string>
9+
<object class="NSMutableDictionary" key="IBDocument.PluginVersions">
10+
<string key="NS.key.0">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
11+
<string key="NS.object.0">1181</string>
12+
</object>
13+
<array key="IBDocument.IntegratedClassDependencies">
14+
<string>IBProxyObject</string>
15+
<string>IBUIView</string>
16+
<string>IBUIWebView</string>
17+
</array>
18+
<array key="IBDocument.PluginDependencies">
19+
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
20+
</array>
21+
<object class="NSMutableDictionary" key="IBDocument.Metadata">
22+
<string key="NS.key.0">PluginDependencyRecalculationVersion</string>
23+
<integer value="1" key="NS.object.0"/>
24+
</object>
25+
<array class="NSMutableArray" key="IBDocument.RootObjects" id="1000">
26+
<object class="IBProxyObject" id="372490531">
27+
<string key="IBProxiedObjectIdentifier">IBFilesOwner</string>
28+
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
29+
</object>
30+
<object class="IBProxyObject" id="975951072">
31+
<string key="IBProxiedObjectIdentifier">IBFirstResponder</string>
32+
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
33+
</object>
34+
<object class="IBUIView" id="191373211">
35+
<reference key="NSNextResponder"/>
36+
<int key="NSvFlags">274</int>
37+
<array class="NSMutableArray" key="NSSubviews">
38+
<object class="IBUIWebView" id="591210866">
39+
<reference key="NSNextResponder" ref="191373211"/>
40+
<int key="NSvFlags">274</int>
41+
<string key="NSFrameSize">{320, 460}</string>
42+
<reference key="NSSuperview" ref="191373211"/>
43+
<reference key="NSWindow"/>
44+
<string key="NSReuseIdentifierKey">_NS:9</string>
45+
<object class="NSColor" key="IBUIBackgroundColor">
46+
<int key="NSColorSpace">1</int>
47+
<bytes key="NSRGB">MSAxIDEAA</bytes>
48+
</object>
49+
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
50+
<int key="IBUIDataDetectorTypes">1</int>
51+
<bool key="IBUIDetectsPhoneNumbers">YES</bool>
52+
</object>
53+
</array>
54+
<string key="NSFrame">{{0, 20}, {320, 460}}</string>
55+
<reference key="NSSuperview"/>
56+
<reference key="NSWindow"/>
57+
<reference key="NSNextKeyView" ref="591210866"/>
58+
<object class="NSColor" key="IBUIBackgroundColor">
59+
<int key="NSColorSpace">3</int>
60+
<bytes key="NSWhite">MQA</bytes>
61+
<object class="NSColorSpace" key="NSCustomColorSpace">
62+
<int key="NSID">2</int>
63+
</object>
64+
</object>
65+
<object class="IBUISimulatedStatusBarMetrics" key="IBUISimulatedStatusBarMetrics"/>
66+
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
67+
</object>
68+
</array>
69+
<object class="IBObjectContainer" key="IBDocument.Objects">
70+
<array class="NSMutableArray" key="connectionRecords">
71+
<object class="IBConnectionRecord">
72+
<object class="IBCocoaTouchOutletConnection" key="connection">
73+
<string key="label">view</string>
74+
<reference key="source" ref="372490531"/>
75+
<reference key="destination" ref="191373211"/>
76+
</object>
77+
<int key="connectionID">3</int>
78+
</object>
79+
<object class="IBConnectionRecord">
80+
<object class="IBCocoaTouchOutletConnection" key="connection">
81+
<string key="label">webView</string>
82+
<reference key="source" ref="372490531"/>
83+
<reference key="destination" ref="591210866"/>
84+
</object>
85+
<int key="connectionID">5</int>
86+
</object>
87+
</array>
88+
<object class="IBMutableOrderedSet" key="objectRecords">
89+
<array key="orderedObjects">
90+
<object class="IBObjectRecord">
91+
<int key="objectID">0</int>
92+
<array key="object" id="0"/>
93+
<reference key="children" ref="1000"/>
94+
<nil key="parent"/>
95+
</object>
96+
<object class="IBObjectRecord">
97+
<int key="objectID">1</int>
98+
<reference key="object" ref="191373211"/>
99+
<array class="NSMutableArray" key="children">
100+
<reference ref="591210866"/>
101+
</array>
102+
<reference key="parent" ref="0"/>
103+
</object>
104+
<object class="IBObjectRecord">
105+
<int key="objectID">-1</int>
106+
<reference key="object" ref="372490531"/>
107+
<reference key="parent" ref="0"/>
108+
<string key="objectName">File's Owner</string>
109+
</object>
110+
<object class="IBObjectRecord">
111+
<int key="objectID">-2</int>
112+
<reference key="object" ref="975951072"/>
113+
<reference key="parent" ref="0"/>
114+
</object>
115+
<object class="IBObjectRecord">
116+
<int key="objectID">4</int>
117+
<reference key="object" ref="591210866"/>
118+
<reference key="parent" ref="191373211"/>
119+
</object>
120+
</array>
121+
</object>
122+
<dictionary class="NSMutableDictionary" key="flattenedProperties">
123+
<string key="-1.CustomClassName">RootViewController</string>
124+
<string key="-1.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
125+
<string key="-2.CustomClassName">UIResponder</string>
126+
<string key="-2.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
127+
<string key="1.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
128+
<string key="4.CustomClassName">FlatWebView</string>
129+
<string key="4.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
130+
</dictionary>
131+
<dictionary class="NSMutableDictionary" key="unlocalizedProperties"/>
132+
<nil key="activeLocalization"/>
133+
<dictionary class="NSMutableDictionary" key="localizations"/>
134+
<nil key="sourceID"/>
135+
<int key="maxID">5</int>
136+
</object>
137+
<object class="IBClassDescriber" key="IBDocument.Classes">
138+
<array class="NSMutableArray" key="referencedPartialClassDescriptions">
139+
<object class="IBPartialClassDescription">
140+
<string key="className">FlatWebView</string>
141+
<string key="superclassName">UIWebView</string>
142+
<object class="IBClassDescriptionSource" key="sourceIdentifier">
143+
<string key="majorKey">IBProjectSource</string>
144+
<string key="minorKey">./Classes/FlatWebView.h</string>
145+
</object>
146+
</object>
147+
<object class="IBPartialClassDescription">
148+
<string key="className">RootViewController</string>
149+
<string key="superclassName">UIViewController</string>
150+
<object class="NSMutableDictionary" key="outlets">
151+
<string key="NS.key.0">webView</string>
152+
<string key="NS.object.0">FlatWebView</string>
153+
</object>
154+
<object class="NSMutableDictionary" key="toOneOutletInfosByName">
155+
<string key="NS.key.0">webView</string>
156+
<object class="IBToOneOutletInfo" key="NS.object.0">
157+
<string key="name">webView</string>
158+
<string key="candidateClassName">FlatWebView</string>
159+
</object>
160+
</object>
161+
<object class="IBClassDescriptionSource" key="sourceIdentifier">
162+
<string key="majorKey">IBProjectSource</string>
163+
<string key="minorKey">./Classes/RootViewController.h</string>
164+
</object>
165+
</object>
166+
</array>
167+
</object>
168+
<int key="IBDocument.localizationMode">0</int>
169+
<string key="IBDocument.TargetRuntimeIdentifier">IBCocoaTouchFramework</string>
170+
<object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDependencyDefaults">
171+
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaTouchPlugin.iPhoneOS</string>
172+
<real value="1296" key="NS.object.0"/>
173+
</object>
174+
<bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool>
175+
<int key="IBDocument.defaultPropertyAccessControl">3</int>
176+
<string key="IBCocoaTouchPluginVersion">1181</string>
177+
</data>
178+
</archive>

FlatWebView.xcodeproj/project.pbxproj

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
1DF5F4E00D08C38300B7A737 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */; };
1414
288765FD0DF74451002DB57D /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 288765FC0DF74451002DB57D /* CoreGraphics.framework */; };
1515
28AD733F0D9D9553002E5188 /* MainWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = 28AD733E0D9D9553002E5188 /* MainWindow.xib */; };
16+
93AA3DCD15A4FEB30095B184 /* RootViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 93AA3DCB15A4FEB30095B184 /* RootViewController.m */; };
17+
93AA3DCE15A4FEB30095B184 /* RootViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 93AA3DCC15A4FEB30095B184 /* RootViewController.xib */; };
1618
93EB8378133D5CBA002CD958 /* FlatWebView.m in Sources */ = {isa = PBXBuildFile; fileRef = 93EB8377133D5CBA002CD958 /* FlatWebView.m */; };
1719
/* End PBXBuildFile section */
1820

@@ -27,6 +29,9 @@
2729
29B97316FDCFA39411CA2CEA /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
2830
32CA4F630368D1EE00C91783 /* FlatWebView_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FlatWebView_Prefix.pch; sourceTree = "<group>"; };
2931
8D1107310486CEB800E47090 /* FlatWebView-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "FlatWebView-Info.plist"; plistStructureDefinitionIdentifier = "com.apple.xcode.plist.structure-definition.iphone.info-plist"; sourceTree = "<group>"; };
32+
93AA3DCA15A4FEB30095B184 /* RootViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RootViewController.h; sourceTree = "<group>"; };
33+
93AA3DCB15A4FEB30095B184 /* RootViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RootViewController.m; sourceTree = "<group>"; };
34+
93AA3DCC15A4FEB30095B184 /* RootViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = RootViewController.xib; sourceTree = "<group>"; };
3035
93EB8376133D5CBA002CD958 /* FlatWebView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FlatWebView.h; sourceTree = "<group>"; };
3136
93EB8377133D5CBA002CD958 /* FlatWebView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FlatWebView.m; sourceTree = "<group>"; };
3237
/* End PBXFileReference section */
@@ -52,6 +57,9 @@
5257
1D3623250D0F684500981E51 /* FlatWebViewAppDelegate.m */,
5358
93EB8376133D5CBA002CD958 /* FlatWebView.h */,
5459
93EB8377133D5CBA002CD958 /* FlatWebView.m */,
60+
93AA3DCA15A4FEB30095B184 /* RootViewController.h */,
61+
93AA3DCB15A4FEB30095B184 /* RootViewController.m */,
62+
93AA3DCC15A4FEB30095B184 /* RootViewController.xib */,
5563
);
5664
path = Classes;
5765
sourceTree = "<group>";
@@ -157,6 +165,7 @@
157165
buildActionMask = 2147483647;
158166
files = (
159167
28AD733F0D9D9553002E5188 /* MainWindow.xib in Resources */,
168+
93AA3DCE15A4FEB30095B184 /* RootViewController.xib in Resources */,
160169
);
161170
runOnlyForDeploymentPostprocessing = 0;
162171
};
@@ -170,6 +179,7 @@
170179
1D60589B0D05DD56006BFB54 /* main.m in Sources */,
171180
1D3623260D0F684500981E51 /* FlatWebViewAppDelegate.m in Sources */,
172181
93EB8378133D5CBA002CD958 /* FlatWebView.m in Sources */,
182+
93AA3DCD15A4FEB30095B184 /* RootViewController.m in Sources */,
173183
);
174184
runOnlyForDeploymentPostprocessing = 0;
175185
};

0 commit comments

Comments
 (0)