Skip to content
Browse files

converted project to ARC, added iPhone 5 support

  • Loading branch information...
1 parent facb8ff commit acbb338a796e0307697d3818ced1cdba5f14a60c @jaydee3 committed Nov 8, 2012
View
7 Classes/AppDelegate.h
@@ -10,9 +10,8 @@
#import "TestViewController.h"
@interface AppDelegate : UIResponder <UIApplicationDelegate>
-{
- UIWindow* mWindow;
- TestViewController* mViewController;
-}
+
+@property (nonatomic,strong) UIWindow *window;
+@property (nonatomic,strong) TestViewController *viewController;
@end
View
17 Classes/AppDelegate.m
@@ -12,23 +12,14 @@ @implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
- mWindow = [[UIWindow alloc] initWithFrame: [[UIScreen mainScreen] bounds]];
- mWindow.backgroundColor = [UIColor whiteColor];
+ self.window = [[UIWindow alloc] initWithFrame: [[UIScreen mainScreen] bounds]];
+ // setup controller
TestViewController* viewController = [[TestViewController alloc] init];
- [mWindow addSubview: viewController.view];
-
- [mWindow makeKeyAndVisible];
+ self.window.rootViewController = viewController;
+ [self.window makeKeyAndVisible];
return YES;
}
-- (void)dealloc
-{
- [mWindow release];
- [mViewController release];
-
- [super dealloc];
-}
-
@end
View
16 Classes/TestViewController.h
@@ -9,16 +9,14 @@
#import "JDDroppableView.h"
@interface TestViewController : UIViewController <JDDroppableViewDelegate>
-{
- UIScrollView* mScrollView;
- UIView* mDropTarget;
-
- CGPoint mLastPosition;
-}
-- (void) relayout;
-- (void) addView: (id) sender;
-- (void) scrollToBottomAnimated: (BOOL) animated;
+@property (nonatomic, strong) UIScrollView *scrollView;
+@property (nonatomic, strong) UIView *dropTarget;
+@property (nonatomic, assign) CGPoint lastPosition;
+
+- (void)relayout;
+- (void)addView:(id)sender;
+- (void)scrollToBottomAnimated:(BOOL)animated;
@end
View
95 Classes/TestViewController.m
@@ -48,29 +48,27 @@ - (void)loadView
[self.view addSubview: button];
// drop target
- mDropTarget = [[UIView alloc] init];
- mDropTarget.autoresizingMask = UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin;
- mDropTarget.backgroundColor = [UIColor orangeColor];
- mDropTarget.frame = CGRectMake(0, 0, 30, 30);
- mDropTarget.center = CGPointMake(self.view.frame.size.width/2, button.frame.origin.y - 50);
- mDropTarget.layer.cornerRadius = 15;
- [self.view addSubview: mDropTarget];
- [mDropTarget release];
+ self.dropTarget = [[UIView alloc] init];
+ self.dropTarget.autoresizingMask = UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin;
+ self.dropTarget.backgroundColor = [UIColor orangeColor];
+ self.dropTarget.frame = CGRectMake(0, 0, 30, 30);
+ self.dropTarget.center = CGPointMake(self.view.frame.size.width/2, button.frame.origin.y - 50);
+ self.dropTarget.layer.cornerRadius = 15;
+ [self.view addSubview: self.dropTarget];
// scrollview
- mScrollView = [[UIScrollView alloc] init];
- mScrollView.autoresizingMask = UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
- mScrollView.backgroundColor = [UIColor colorWithRed: 0.75 green: 0.2 blue: 0 alpha: 1.0];
- mScrollView.indicatorStyle = UIScrollViewIndicatorStyleWhite;
- mScrollView.scrollIndicatorInsets = UIEdgeInsetsMake(5, 5, 5, 5);
- mScrollView.contentInset = UIEdgeInsetsMake(6, 6, 6, 6);
- mScrollView.layer.cornerRadius = 5.0;
- mScrollView.frame = CGRectMake(20,20, self.view.frame.size.width - 40, mDropTarget.center.y - 70);
- mScrollView.userInteractionEnabled = NO;
- mScrollView.canCancelContentTouches = NO;
-
- [self.view addSubview: mScrollView];
- [mScrollView release];
+ self.scrollView = [[UIScrollView alloc] init];
+ self.scrollView.autoresizingMask = UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
+ self.scrollView.backgroundColor = [UIColor colorWithRed: 0.75 green: 0.2 blue: 0 alpha: 1.0];
+ self.scrollView.indicatorStyle = UIScrollViewIndicatorStyleWhite;
+ self.scrollView.scrollIndicatorInsets = UIEdgeInsetsMake(5, 5, 5, 5);
+ self.scrollView.contentInset = UIEdgeInsetsMake(6, 6, 6, 6);
+ self.scrollView.layer.cornerRadius = 5.0;
+ self.scrollView.frame = CGRectMake(20,20, self.view.frame.size.width - 40, self.dropTarget.center.y - 70);
+ self.scrollView.userInteractionEnabled = NO;
+ self.scrollView.canCancelContentTouches = NO;
+
+ [self.view addSubview: self.scrollView];
// animate some draggable views in
int numberOfViews = sCOUNT_OF_VIEWS_HORICONTALLY*floor(sCOUNT_OF_VIEWS_VERTICALLY) + 2;
@@ -83,16 +81,16 @@ - (void)loadView
}
// reenable userinteraction after animation ended
- [mScrollView performSelector: @selector(setUserInteractionEnabled:) withObject: [NSNumber numberWithBool: YES] afterDelay: numberOfViews*animationTimePerView];
+ [self.scrollView performSelector: @selector(setUserInteractionEnabled:) withObject: [NSNumber numberWithBool: YES] afterDelay: numberOfViews*animationTimePerView];
}
#pragma layout
-- (void) relayout
+- (void)relayout
{
// cancel all animations
- [mScrollView.layer removeAllAnimations];
- for (UIView* subview in mScrollView.subviews)
+ [self.scrollView.layer removeAllAnimations];
+ for (UIView* subview in self.scrollView.subviews)
[subview.layer removeAllAnimations];
// setup new animation
@@ -102,11 +100,11 @@ - (void) relayout
float posx = 0;
float posy = 0;
CGRect frame = CGRectZero;
- mLastPosition = CGPointMake(0, -100);
- CGFloat contentWidth = mScrollView.contentSize.width - mScrollView.contentInset.left - mScrollView.contentInset.right;
+ self.lastPosition = CGPointMake(0, -100);
+ CGFloat contentWidth = self.scrollView.contentSize.width - self.scrollView.contentInset.left - self.scrollView.contentInset.right;
// iterate through all subviews
- for (UIView* subview in mScrollView.subviews)
+ for (UIView* subview in self.scrollView.subviews)
{
// ignore scroll indicators
if (!subview.userInteractionEnabled) {
@@ -125,13 +123,13 @@ - (void) relayout
}
// save last position
- mLastPosition = CGPointMake(posx, posy);
+ self.lastPosition = CGPointMake(posx, posy);
// add size and margin
posx += frame.size.width + sDROPVIEW_MARGIN;
// goto next row if needed
- if (posx > mScrollView.frame.size.width - mScrollView.contentInset.left - mScrollView.contentInset.right)
+ if (posx > self.scrollView.frame.size.width - self.scrollView.contentInset.left - self.scrollView.contentInset.right)
{
posx = 0;
posy += frame.size.height + sDROPVIEW_MARGIN;
@@ -146,26 +144,25 @@ - (void) relayout
}
// update content size
- mScrollView.contentSize = CGSizeMake(contentWidth, posy);
+ self.scrollView.contentSize = CGSizeMake(contentWidth, posy);
[UIView commitAnimations];
}
-- (void) addView: (id) sender
+- (void)addView:(id)sender
{
- CGFloat contentWidth = mScrollView.frame.size.width - mScrollView.contentInset.left - mScrollView.contentInset.right;
- CGFloat contentHeight = mScrollView.frame.size.height - mScrollView.contentInset.top;
+ CGFloat contentWidth = self.scrollView.frame.size.width - self.scrollView.contentInset.left - self.scrollView.contentInset.right;
+ CGFloat contentHeight = self.scrollView.frame.size.height - self.scrollView.contentInset.top;
CGSize size = CGSizeMake(((contentWidth-sDROPVIEW_MARGIN*(sCOUNT_OF_VIEWS_HORICONTALLY-1))/sCOUNT_OF_VIEWS_HORICONTALLY),
floor((contentHeight-sDROPVIEW_MARGIN*(sCOUNT_OF_VIEWS_VERTICALLY-1))/sCOUNT_OF_VIEWS_VERTICALLY));
- JDDroppableView * dropview = [[JDDroppableView alloc] initWithDropTarget: mDropTarget];
+ JDDroppableView * dropview = [[JDDroppableView alloc] initWithDropTarget: self.dropTarget];
dropview.backgroundColor = [UIColor blackColor];
dropview.layer.cornerRadius = 3.0;
- dropview.frame = CGRectMake(mLastPosition.x, mLastPosition.y, size.width, size.height);
+ dropview.frame = CGRectMake(self.lastPosition.x, self.lastPosition.y, size.width, size.height);
dropview.delegate = self;
- [mScrollView addSubview: dropview];
- [dropview release];
+ [self.scrollView addSubview: dropview];
[self relayout];
@@ -175,17 +172,17 @@ - (void) addView: (id) sender
}
}
-- (void) scrollToBottomAnimated: (BOOL) animated
+- (void)scrollToBottomAnimated:(BOOL)animated
{
- [mScrollView.layer removeAllAnimations];
-
- CGFloat bottomScrollPosition = mScrollView.contentSize.height;
- bottomScrollPosition -= mScrollView.frame.size.height;
- bottomScrollPosition += mScrollView.contentInset.top;
- bottomScrollPosition = MAX(-mScrollView.contentInset.top,bottomScrollPosition);
- CGPoint newOffset = CGPointMake(-mScrollView.contentInset.left, bottomScrollPosition);
- if (newOffset.y != mScrollView.contentOffset.y) {
- [mScrollView setContentOffset: newOffset animated: animated];
+ [self.scrollView.layer removeAllAnimations];
+
+ CGFloat bottomScrollPosition = self.scrollView.contentSize.height;
+ bottomScrollPosition -= self.scrollView.frame.size.height;
+ bottomScrollPosition += self.scrollView.contentInset.top;
+ bottomScrollPosition = MAX(-self.scrollView.contentInset.top,bottomScrollPosition);
+ CGPoint newOffset = CGPointMake(-self.scrollView.contentInset.left, bottomScrollPosition);
+ if (newOffset.y != self.scrollView.contentOffset.y) {
+ [self.scrollView setContentOffset: newOffset animated: animated];
}
}
@@ -212,7 +209,7 @@ - (BOOL) shouldAnimateDroppableViewBack: (JDDroppableView *)view wasDroppedOnTar
[UIView commitAnimations];
[self relayout];
- [mScrollView flashScrollIndicators];
+ [self.scrollView flashScrollIndicators];
return NO;
}
View
19 DroppableViewTest.xcodeproj/project.pbxproj
@@ -7,6 +7,7 @@
objects = {
/* Begin PBXBuildFile section */
+ D2652E99164C0DB000C49837 /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = D2652E98164C0DB000C49837 /* Default-568h@2x.png */; };
D272CB0D151FA4EF006F8770 /* icon.png in Resources */ = {isa = PBXBuildFile; fileRef = D272CB0B151FA4EF006F8770 /* icon.png */; };
D272CB0E151FA4EF006F8770 /* icon@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = D272CB0C151FA4EF006F8770 /* icon@2x.png */; };
D286AD5C151F966E00110CE1 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D286AD5B151F966E00110CE1 /* UIKit.framework */; };
@@ -22,6 +23,7 @@
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
+ D2652E98164C0DB000C49837 /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-568h@2x.png"; sourceTree = "<group>"; };
D272CB0B151FA4EF006F8770 /* icon.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = icon.png; sourceTree = "<group>"; };
D272CB0C151FA4EF006F8770 /* icon@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "icon@2x.png"; sourceTree = "<group>"; };
D286AD57151F966E00110CE1 /* DroppableViewTest.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = DroppableViewTest.app; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -70,6 +72,7 @@
children = (
D2F52C2F151FA85F004241E6 /* Default.png */,
D2F52C30151FA85F004241E6 /* Default@2x.png */,
+ D2652E98164C0DB000C49837 /* Default-568h@2x.png */,
D272CB0B151FA4EF006F8770 /* icon.png */,
D272CB0C151FA4EF006F8770 /* icon@2x.png */,
);
@@ -199,6 +202,7 @@
D272CB0E151FA4EF006F8770 /* icon@2x.png in Resources */,
D2F52C31151FA85F004241E6 /* Default.png in Resources */,
D2F52C32151FA85F004241E6 /* Default@2x.png in Resources */,
+ D2652E99164C0DB000C49837 /* Default-568h@2x.png in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -223,25 +227,15 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
- ARCHS = (
- armv6,
- armv7,
- );
+ CLANG_ENABLE_OBJC_ARC = YES;
COPY_PHASE_STRIP = NO;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_OPTIMIZATION_LEVEL = 0;
- GCC_PREPROCESSOR_DEFINITIONS = (
- "DEBUG=1",
- "$(inherited)",
- );
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
- GCC_THUMB_SUPPORT = NO;
- GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
- IPHONEOS_DEPLOYMENT_TARGET = 3.0;
SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2";
};
@@ -250,10 +244,11 @@
D286AD70151F966E00110CE1 /* Default */ = {
isa = XCBuildConfiguration;
buildSettings = {
+ CLANG_ENABLE_OBJC_ARC = YES;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = SupportingFiles/Prefix.pch;
- GCC_THUMB_SUPPORT = NO;
INFOPLIST_FILE = SupportingFiles/Info.plist;
+ IPHONEOS_DEPLOYMENT_TARGET = 5.0;
PRODUCT_NAME = "$(TARGET_NAME)";
WRAPPER_EXTENSION = app;
};
View
45 Library/DroppableView/JDDroppableView.h
@@ -8,33 +8,28 @@
@class JDDroppableView;
-
-@protocol JDDroppableViewDelegate <NSObject>
-@optional
-- (void) droppableViewBeganDragging: (JDDroppableView*) view;
-- (void) droppableViewDidMove: (JDDroppableView*) view;
-- (void) droppableView: (JDDroppableView*) view enteredTarget: (UIView*) target;
-- (void) droppableView: (JDDroppableView*) view leftTarget: (UIView*) target;
-- (BOOL) shouldAnimateDroppableViewBack: (JDDroppableView*) view wasDroppedOnTarget: (UIView*) target;
-- (void) droppableViewEndedDragging: (JDDroppableView*) view;
-@end
+@protocol JDDroppableViewDelegate;
@interface JDDroppableView : UIView
-{
- UIView * mDropTarget;
-
- UIView * mOuterView;
- UIScrollView * mScrollView;
-
- BOOL mIsDragging;
- BOOL mIsOverTarget;
- CGPoint mOriginalPosition;
-}
-
-@property (nonatomic, assign) id<JDDroppableViewDelegate> delegate;
-
-- (id) initWithFrame:(CGRect)frame;
-- (id) initWithDropTarget:(UIView*)target;
+
+@property (nonatomic, weak) id<JDDroppableViewDelegate> delegate;
+
+- (id)initWithFrame:(CGRect)frame;
+- (id)initWithDropTarget:(UIView*)target;
@end
+
+
+
+// JDDroppableViewDelegate
+
+@protocol JDDroppableViewDelegate <NSObject>
+@optional
+- (void)droppableViewBeganDragging:(JDDroppableView*)view;
+- (void)droppableViewDidMove:(JDDroppableView*)view;
+- (void)droppableView:(JDDroppableView*)view enteredTarget:(UIView*)target;
+- (void)droppableView:(JDDroppableView*)view leftTarget:(UIView*)target;
+- (BOOL)shouldAnimateDroppableViewBack:(JDDroppableView*)view wasDroppedOnTarget:(UIView*)target;
+- (void)droppableViewEndedDragging:(JDDroppableView*)view;
+@end
View
102 Library/DroppableView/JDDroppableView.m
@@ -9,7 +9,14 @@
#import "JDDroppableView.h"
-@interface JDDroppableView (hidden)
+@interface JDDroppableView ()
+@property (nonatomic, weak) UIView *dropTarget;
+@property (nonatomic, weak) UIView *outerView;
+@property (nonatomic, weak) UIScrollView *scrollView;
+@property (nonatomic, assign) BOOL isDragging;
+@property (nonatomic, assign) BOOL isOverTarget;
+@property (nonatomic, assign) CGPoint originalPosition;
+
- (void) beginDrag;
- (void) dragAtPosition: (UITouch *) touch;
- (void) endDrag;
@@ -22,8 +29,6 @@ - (BOOL) handleDroppedView;
@implementation JDDroppableView
-@synthesize delegate = _delegate;
-
- (id)init
{
return [self initWithFrame: [UIApplication sharedApplication].keyWindow.frame];
@@ -33,8 +38,8 @@ - (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
- mIsDragging = NO;
- mIsOverTarget = NO;
+ self.isDragging = NO;
+ self.isOverTarget = NO;
}
return self;
}
@@ -43,48 +48,49 @@ - (id) initWithDropTarget: (UIView *) target;
{
self = [self init];
if (self != nil) {
- mDropTarget = target;
+ self.dropTarget = target;
}
return self;
}
-#pragma mark touch handling
+#pragma mark UIResponder (touch handling)
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
+ [super touchesBegan:touches withEvent:event];
[self beginDrag];
[self dragAtPosition: [touches anyObject]];
}
-
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
+ [super touchesMoved:touches withEvent:event];
[self dragAtPosition: [touches anyObject]];
}
-
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
-{
+{
+ [super touchesEnded:touches withEvent:event];
[self endDrag];
}
-
- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event
{
+ [super touchesCancelled:touches withEvent:event];
[self endDrag];
}
#pragma mark dragging logic
- (void) beginDrag
{
- mIsDragging = YES;
+ self.isDragging = YES;
- if ([_delegate respondsToSelector: @selector(droppableViewBeganDragging:)]) {
- [_delegate droppableViewBeganDragging: self];
+ if ([self.delegate respondsToSelector: @selector(droppableViewBeganDragging:)]) {
+ [self.delegate droppableViewBeganDragging: self];
};
- mOriginalPosition = self.center;
+ self.originalPosition = self.center;
[self changeSuperView];
}
@@ -96,29 +102,29 @@ - (void) dragAtPosition: (UITouch *) touch
self.center = [touch locationInView: self.superview];
[UIView commitAnimations];
- if ([_delegate respondsToSelector: @selector(droppableViewDidMove:)]) {
- [_delegate droppableViewDidMove:self];
+ if ([self.delegate respondsToSelector: @selector(droppableViewDidMove:)]) {
+ [self.delegate droppableViewDidMove:self];
}
- if (mDropTarget) {
- CGRect intersect = CGRectIntersection(self.frame, mDropTarget.frame);
+ if (self.dropTarget) {
+ CGRect intersect = CGRectIntersection(self.frame, self.dropTarget.frame);
if (intersect.size.width > 10 || intersect.size.height > 10)
{
- if (!mIsOverTarget)
+ if (!self.isOverTarget)
{
- mIsOverTarget = YES;
+ self.isOverTarget = YES;
- if ([_delegate respondsToSelector: @selector(droppableView:enteredTarget:)]) {
- [_delegate droppableView: self enteredTarget: mDropTarget];
+ if ([self.delegate respondsToSelector: @selector(droppableView:enteredTarget:)]) {
+ [self.delegate droppableView: self enteredTarget: self.dropTarget];
}
}
}
- else if (mIsOverTarget)
+ else if (self.isOverTarget)
{
- mIsOverTarget = NO;
+ self.isOverTarget = NO;
- if ([_delegate respondsToSelector: @selector(droppableView:leftTarget:)]) {
- [_delegate droppableView: self leftTarget: mDropTarget];
+ if ([self.delegate respondsToSelector: @selector(droppableView:leftTarget:)]) {
+ [self.delegate droppableView: self leftTarget: self.dropTarget];
}
}
}
@@ -127,35 +133,35 @@ - (void) dragAtPosition: (UITouch *) touch
- (void) endDrag
{
- mIsOverTarget = NO;
+ self.isOverTarget = NO;
- if([_delegate respondsToSelector: @selector(droppableViewEndedDragging:)]) {
- [_delegate droppableViewEndedDragging: self];
+ if([self.delegate respondsToSelector: @selector(droppableViewEndedDragging:)]) {
+ [self.delegate droppableViewEndedDragging: self];
}
- if (mDropTarget) {
- CGRect intersect = CGRectIntersection(self.frame, mDropTarget.frame);
+ if (self.dropTarget) {
+ CGRect intersect = CGRectIntersection(self.frame, self.dropTarget.frame);
if (intersect.size.width > 10 || intersect.size.height > 10) {
if([self handleDroppedView]) {
- mIsDragging = NO;
+ self.isDragging = NO;
return;
}
}
}
[self changeSuperView];
- mIsDragging = NO; // this needs to be after superview change
+ self.isDragging = NO; // this needs to be after superview change
[UIView beginAnimations: @"drag" context: nil];
- self.center = mOriginalPosition;
+ self.center = self.originalPosition;
[UIView commitAnimations];
}
- (BOOL) handleDroppedView
{
- if (mDropTarget && [_delegate respondsToSelector: @selector(shouldAnimateDroppableViewBack:wasDroppedOnTarget:)]) {
- return ![_delegate shouldAnimateDroppableViewBack: self wasDroppedOnTarget: mDropTarget];
+ if (self.dropTarget && [self.delegate respondsToSelector: @selector(shouldAnimateDroppableViewBack:wasDroppedOnTarget:)]) {
+ return ![self.delegate shouldAnimateDroppableViewBack: self wasDroppedOnTarget: self.dropTarget];
}
return NO;
@@ -165,38 +171,38 @@ - (BOOL) handleDroppedView
- (void)willMoveToSuperview:(id)newSuperview
{
- if (!mIsDragging && [newSuperview isKindOfClass: [UIScrollView class]]) {
- mScrollView = newSuperview;
- mOuterView = mScrollView.superview;
+ if (!self.isDragging && [newSuperview isKindOfClass: [UIScrollView class]]) {
+ self.scrollView = newSuperview;
+ self.outerView = self.scrollView.superview;
}
}
- (void) changeSuperView
{
- if (!mScrollView) {
+ if (!self.scrollView) {
[self.superview bringSubviewToFront: self];
return;
}
UIView * tmp = self.superview;
[self removeFromSuperview];
- [mOuterView addSubview: self];
+ [self.outerView addSubview: self];
- mOuterView = tmp;
+ self.outerView = tmp;
// set new position
CGPoint ctr = self.center;
- if (mOuterView == mScrollView) {
+ if (self.outerView == self.scrollView) {
- ctr.x += mScrollView.frame.origin.x - mScrollView.contentOffset.x;
- ctr.y += mScrollView.frame.origin.y - mScrollView.contentOffset.y;
+ ctr.x += self.scrollView.frame.origin.x - self.scrollView.contentOffset.x;
+ ctr.y += self.scrollView.frame.origin.y - self.scrollView.contentOffset.y;
} else {
- ctr.x -= mScrollView.frame.origin.x - mScrollView.contentOffset.x;
- ctr.y -= mScrollView.frame.origin.y - mScrollView.contentOffset.y;
+ ctr.x -= self.scrollView.frame.origin.x - self.scrollView.contentOffset.x;
+ ctr.y -= self.scrollView.frame.origin.y - self.scrollView.contentOffset.y;
}
self.center = ctr;
View
BIN Ressources/images/Default-568h@2x.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN Ressources/images/Default.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN Ressources/images/Default@2x.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 acbb338

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