Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Added possibility for ScrollViews to add non-scaling subviews, taken …

…from Book iOS Recipes
  • Loading branch information...
commit de3d49ca0f8bc4d062ef3f5061b8d48162cd4f21 1 parent 84a39cc
Matthias Tretter authored
16  PSFoundation.xcodeproj/project.pbxproj
@@ -43,6 +43,8 @@
43 43
 		39C9181A1398D7AC0045489C /* MTSplashScreenDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 39C918191398D7AC0045489C /* MTSplashScreenDelegate.h */; };
44 44
 		39D8262F12E364530079B785 /* UIView+Hierarchy.h in Headers */ = {isa = PBXBuildFile; fileRef = 39D8262D12E364530079B785 /* UIView+Hierarchy.h */; };
45 45
 		39D8263012E364530079B785 /* UIView+Hierarchy.m in Sources */ = {isa = PBXBuildFile; fileRef = 39D8262E12E364530079B785 /* UIView+Hierarchy.m */; };
  46
+		39DDF4D4139FE7CB000B76BD /* PSScrollContentView.h in Headers */ = {isa = PBXBuildFile; fileRef = 39DDF4D2139FE7CB000B76BD /* PSScrollContentView.h */; };
  47
+		39DDF4D5139FE7CB000B76BD /* PSScrollContentView.m in Sources */ = {isa = PBXBuildFile; fileRef = 39DDF4D3139FE7CB000B76BD /* PSScrollContentView.m */; };
46 48
 		39EBAAB113508EE100BBFB4B /* UIViewController+MTAnimatedFetch.h in Headers */ = {isa = PBXBuildFile; fileRef = 39EBAAAF13508EE100BBFB4B /* UIViewController+MTAnimatedFetch.h */; };
47 49
 		39EE4117136ABFE300ABE900 /* UIView+WhenTappedBlocks.h in Headers */ = {isa = PBXBuildFile; fileRef = 39EE4113136ABFE300ABE900 /* UIView+WhenTappedBlocks.h */; };
48 50
 		39EE4118136ABFE300ABE900 /* UIView+WhenTappedBlocks.m in Sources */ = {isa = PBXBuildFile; fileRef = 39EE4114136ABFE300ABE900 /* UIView+WhenTappedBlocks.m */; };
@@ -618,6 +620,8 @@
618 620
 		39C918191398D7AC0045489C /* MTSplashScreenDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MTSplashScreenDelegate.h; sourceTree = "<group>"; };
619 621
 		39D8262D12E364530079B785 /* UIView+Hierarchy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "UIView+Hierarchy.h"; path = "Categories/UIView/UIView+Hierarchy.h"; sourceTree = SOURCE_ROOT; };
620 622
 		39D8262E12E364530079B785 /* UIView+Hierarchy.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "UIView+Hierarchy.m"; path = "Categories/UIView/UIView+Hierarchy.m"; sourceTree = SOURCE_ROOT; };
  623
+		39DDF4D2139FE7CB000B76BD /* PSScrollContentView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PSScrollContentView.h; sourceTree = "<group>"; };
  624
+		39DDF4D3139FE7CB000B76BD /* PSScrollContentView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PSScrollContentView.m; sourceTree = "<group>"; };
621 625
 		39EBAAAF13508EE100BBFB4B /* UIViewController+MTAnimatedFetch.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIViewController+MTAnimatedFetch.h"; sourceTree = "<group>"; };
622 626
 		39EBAAB013508EE100BBFB4B /* UIViewController+MTAnimatedFetch.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIViewController+MTAnimatedFetch.m"; sourceTree = "<group>"; };
623 627
 		39EE4113136ABFE300ABE900 /* UIView+WhenTappedBlocks.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIView+WhenTappedBlocks.h"; sourceTree = "<group>"; };
@@ -991,6 +995,7 @@
991 995
 				7869213E126B4195000259AC /* Macros */,
992 996
 				78692140126B4195000259AC /* Network */,
993 997
 				78692143126B4195000259AC /* Reachability */,
  998
+				39DDF4D1139FE7B6000B76BD /* ScrollView */,
994 999
 				78692146126B4195000259AC /* Sound */,
995 1000
 				39C918141398D73A0045489C /* Splash Screen */,
996 1001
 				78692149126B4195000259AC /* TableView */,
@@ -1080,6 +1085,15 @@
1080 1085
 			name = "Splash Screen";
1081 1086
 			sourceTree = "<group>";
1082 1087
 		};
  1088
+		39DDF4D1139FE7B6000B76BD /* ScrollView */ = {
  1089
+			isa = PBXGroup;
  1090
+			children = (
  1091
+				39DDF4D2139FE7CB000B76BD /* PSScrollContentView.h */,
  1092
+				39DDF4D3139FE7CB000B76BD /* PSScrollContentView.m */,
  1093
+			);
  1094
+			name = ScrollView;
  1095
+			sourceTree = "<group>";
  1096
+		};
1083 1097
 		39EE410F136ABFC800ABE900 /* JMWhenTapped */ = {
1084 1098
 			isa = PBXGroup;
1085 1099
 			children = (
@@ -2070,6 +2084,7 @@
2070 2084
 				39C918171398D7580045489C /* MTSplashScreen.h in Headers */,
2071 2085
 				39C9181A1398D7AC0045489C /* MTSplashScreenDelegate.h in Headers */,
2072 2086
 				39F258B31399587C0084A471 /* UIView+MTRotation.h in Headers */,
  2087
+				39DDF4D4139FE7CB000B76BD /* PSScrollContentView.h in Headers */,
2073 2088
 			);
2074 2089
 			runOnlyForDeploymentPostprocessing = 0;
2075 2090
 		};
@@ -2500,6 +2515,7 @@
2500 2515
 				39483F151396488A00AA4C4E /* UIViewController+MTUIAdditions.m in Sources */,
2501 2516
 				39C918181398D7580045489C /* MTSplashScreen.m in Sources */,
2502 2517
 				39F258B41399587C0084A471 /* UIView+MTRotation.m in Sources */,
  2518
+				39DDF4D5139FE7CB000B76BD /* PSScrollContentView.m in Sources */,
2503 2519
 			);
2504 2520
 			runOnlyForDeploymentPostprocessing = 0;
2505 2521
 		};
23  PSScrollContentView.h
... ...
@@ -0,0 +1,23 @@
  1
+//
  2
+//  PSScrollContentView.h
  3
+//  ScrollViewPins
  4
+//
  5
+//  Created by Matt Drance on 2/22/11.
  6
+//  Copyright 2011 Bookhouse Software LLC. All rights reserved.
  7
+//
  8
+
  9
+#import <UIKit/UIKit.h>
  10
+
  11
+/**
  12
+ * A contentView of a ScrollView that can have non-scaling subviews like 
  13
+ * the pins on a MKMapView
  14
+ */
  15
+@interface PSScrollContentView : UIView {
  16
+    NSMutableSet *nonScalingSubviews_;
  17
+}
  18
+
  19
+@property (nonatomic, readonly, retain) NSMutableSet *nonScalingSubviews;
  20
+
  21
+- (void)addNonScalingSubview:(UIView *)view;
  22
+
  23
+@end
60  PSScrollContentView.m
... ...
@@ -0,0 +1,60 @@
  1
+//
  2
+//  PRPScrollContentView.m
  3
+//  ScrollViewPins
  4
+//
  5
+//  Created by Matt Drance on 2/22/11.
  6
+//  Copyright 2011 Bookhouse Software LLC. All rights reserved.
  7
+//
  8
+
  9
+#import "PSScrollContentView.h"
  10
+
  11
+@interface PSScrollContentView ()
  12
+
  13
+- (void)adjustSubviewsForTransform:(CGAffineTransform)transform;
  14
+
  15
+@end
  16
+
  17
+@implementation PSScrollContentView
  18
+
  19
+@synthesize nonScalingSubviews = nonScalingSubviews_;
  20
+
  21
+- (void)dealloc {
  22
+    MCRelease(nonScalingSubviews_);
  23
+    
  24
+    [super dealloc];
  25
+}
  26
+
  27
+#pragma mark -
  28
+#pragma mark Accessors
  29
+
  30
+- (NSMutableSet *)nonScalingSubviews {
  31
+    if (nonScalingSubviews_ == nil) {
  32
+        nonScalingSubviews_ = [[NSMutableSet alloc] init];
  33
+    }
  34
+    
  35
+    return nonScalingSubviews_;
  36
+}
  37
+
  38
+- (void)addNonScalingSubview:(UIView *)view {
  39
+    [self.nonScalingSubviews addObject:view];
  40
+    [self addSubview:view];
  41
+}
  42
+
  43
+#pragma mark -
  44
+#pragma mark (Non-)Scaling support
  45
+
  46
+
  47
+- (void)setTransform:(CGAffineTransform)transform {
  48
+    [super setTransform:transform];
  49
+    [self adjustSubviewsForTransform:transform];
  50
+}
  51
+
  52
+
  53
+- (void)adjustSubviewsForTransform:(CGAffineTransform)transform {
  54
+    CGAffineTransform inversion = CGAffineTransformInvert(transform);
  55
+    for (UIView *subview in self.nonScalingSubviews) {
  56
+        subview.transform = inversion;
  57
+    }
  58
+}
  59
+
  60
+@end

0 notes on commit de3d49c

Please sign in to comment.
Something went wrong with that request. Please try again.