Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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

…from Book iOS Recipes
  • Loading branch information...
commit de3d49ca0f8bc4d062ef3f5061b8d48162cd4f21 1 parent 84a39cc
@myell0w myell0w authored
View
16 PSFoundation.xcodeproj/project.pbxproj
@@ -43,6 +43,8 @@
39C9181A1398D7AC0045489C /* MTSplashScreenDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 39C918191398D7AC0045489C /* MTSplashScreenDelegate.h */; };
39D8262F12E364530079B785 /* UIView+Hierarchy.h in Headers */ = {isa = PBXBuildFile; fileRef = 39D8262D12E364530079B785 /* UIView+Hierarchy.h */; };
39D8263012E364530079B785 /* UIView+Hierarchy.m in Sources */ = {isa = PBXBuildFile; fileRef = 39D8262E12E364530079B785 /* UIView+Hierarchy.m */; };
+ 39DDF4D4139FE7CB000B76BD /* PSScrollContentView.h in Headers */ = {isa = PBXBuildFile; fileRef = 39DDF4D2139FE7CB000B76BD /* PSScrollContentView.h */; };
+ 39DDF4D5139FE7CB000B76BD /* PSScrollContentView.m in Sources */ = {isa = PBXBuildFile; fileRef = 39DDF4D3139FE7CB000B76BD /* PSScrollContentView.m */; };
39EBAAB113508EE100BBFB4B /* UIViewController+MTAnimatedFetch.h in Headers */ = {isa = PBXBuildFile; fileRef = 39EBAAAF13508EE100BBFB4B /* UIViewController+MTAnimatedFetch.h */; };
39EE4117136ABFE300ABE900 /* UIView+WhenTappedBlocks.h in Headers */ = {isa = PBXBuildFile; fileRef = 39EE4113136ABFE300ABE900 /* UIView+WhenTappedBlocks.h */; };
39EE4118136ABFE300ABE900 /* UIView+WhenTappedBlocks.m in Sources */ = {isa = PBXBuildFile; fileRef = 39EE4114136ABFE300ABE900 /* UIView+WhenTappedBlocks.m */; };
@@ -618,6 +620,8 @@
39C918191398D7AC0045489C /* MTSplashScreenDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MTSplashScreenDelegate.h; sourceTree = "<group>"; };
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; };
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; };
+ 39DDF4D2139FE7CB000B76BD /* PSScrollContentView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PSScrollContentView.h; sourceTree = "<group>"; };
+ 39DDF4D3139FE7CB000B76BD /* PSScrollContentView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PSScrollContentView.m; sourceTree = "<group>"; };
39EBAAAF13508EE100BBFB4B /* UIViewController+MTAnimatedFetch.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIViewController+MTAnimatedFetch.h"; sourceTree = "<group>"; };
39EBAAB013508EE100BBFB4B /* UIViewController+MTAnimatedFetch.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIViewController+MTAnimatedFetch.m"; sourceTree = "<group>"; };
39EE4113136ABFE300ABE900 /* UIView+WhenTappedBlocks.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIView+WhenTappedBlocks.h"; sourceTree = "<group>"; };
@@ -991,6 +995,7 @@
7869213E126B4195000259AC /* Macros */,
78692140126B4195000259AC /* Network */,
78692143126B4195000259AC /* Reachability */,
+ 39DDF4D1139FE7B6000B76BD /* ScrollView */,
78692146126B4195000259AC /* Sound */,
39C918141398D73A0045489C /* Splash Screen */,
78692149126B4195000259AC /* TableView */,
@@ -1080,6 +1085,15 @@
name = "Splash Screen";
sourceTree = "<group>";
};
+ 39DDF4D1139FE7B6000B76BD /* ScrollView */ = {
+ isa = PBXGroup;
+ children = (
+ 39DDF4D2139FE7CB000B76BD /* PSScrollContentView.h */,
+ 39DDF4D3139FE7CB000B76BD /* PSScrollContentView.m */,
+ );
+ name = ScrollView;
+ sourceTree = "<group>";
+ };
39EE410F136ABFC800ABE900 /* JMWhenTapped */ = {
isa = PBXGroup;
children = (
@@ -2070,6 +2084,7 @@
39C918171398D7580045489C /* MTSplashScreen.h in Headers */,
39C9181A1398D7AC0045489C /* MTSplashScreenDelegate.h in Headers */,
39F258B31399587C0084A471 /* UIView+MTRotation.h in Headers */,
+ 39DDF4D4139FE7CB000B76BD /* PSScrollContentView.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -2500,6 +2515,7 @@
39483F151396488A00AA4C4E /* UIViewController+MTUIAdditions.m in Sources */,
39C918181398D7580045489C /* MTSplashScreen.m in Sources */,
39F258B41399587C0084A471 /* UIView+MTRotation.m in Sources */,
+ 39DDF4D5139FE7CB000B76BD /* PSScrollContentView.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
View
23 PSScrollContentView.h
@@ -0,0 +1,23 @@
+//
+// PSScrollContentView.h
+// ScrollViewPins
+//
+// Created by Matt Drance on 2/22/11.
+// Copyright 2011 Bookhouse Software LLC. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+/**
+ * A contentView of a ScrollView that can have non-scaling subviews like
+ * the pins on a MKMapView
+ */
+@interface PSScrollContentView : UIView {
+ NSMutableSet *nonScalingSubviews_;
+}
+
+@property (nonatomic, readonly, retain) NSMutableSet *nonScalingSubviews;
+
+- (void)addNonScalingSubview:(UIView *)view;
+
+@end
View
60 PSScrollContentView.m
@@ -0,0 +1,60 @@
+//
+// PRPScrollContentView.m
+// ScrollViewPins
+//
+// Created by Matt Drance on 2/22/11.
+// Copyright 2011 Bookhouse Software LLC. All rights reserved.
+//
+
+#import "PSScrollContentView.h"
+
+@interface PSScrollContentView ()
+
+- (void)adjustSubviewsForTransform:(CGAffineTransform)transform;
+
+@end
+
+@implementation PSScrollContentView
+
+@synthesize nonScalingSubviews = nonScalingSubviews_;
+
+- (void)dealloc {
+ MCRelease(nonScalingSubviews_);
+
+ [super dealloc];
+}
+
+#pragma mark -
+#pragma mark Accessors
+
+- (NSMutableSet *)nonScalingSubviews {
+ if (nonScalingSubviews_ == nil) {
+ nonScalingSubviews_ = [[NSMutableSet alloc] init];
+ }
+
+ return nonScalingSubviews_;
+}
+
+- (void)addNonScalingSubview:(UIView *)view {
+ [self.nonScalingSubviews addObject:view];
+ [self addSubview:view];
+}
+
+#pragma mark -
+#pragma mark (Non-)Scaling support
+
+
+- (void)setTransform:(CGAffineTransform)transform {
+ [super setTransform:transform];
+ [self adjustSubviewsForTransform:transform];
+}
+
+
+- (void)adjustSubviewsForTransform:(CGAffineTransform)transform {
+ CGAffineTransform inversion = CGAffineTransformInvert(transform);
+ for (UIView *subview in self.nonScalingSubviews) {
+ subview.transform = inversion;
+ }
+}
+
+@end
Please sign in to comment.
Something went wrong with that request. Please try again.