Skip to content
Browse files

Merge from develop

  • Loading branch information...
2 parents e4dff0a + a9af11f commit dcf12437d1f772e685e931b9d80588b71bac7f70 @gmoledina committed
Showing with 1,376 additions and 856 deletions.
  1. +1 −0 .gitignore
  2. 0 {GMGridView → Example}/AppDelegate.h
  3. 0 {GMGridView → Example}/AppDelegate.m
  4. 0 {GMGridView → Example}/Demo1ViewController.h
  5. +104 −31 {GMGridView → Example}/Demo1ViewController.m
  6. 0 {GMGridView → Example}/Demo2ViewController.h
  7. +10 −15 {GMGridView → Example}/Demo2ViewController.m
  8. 0 {GMGridView → Example}/GMGridView-Info.plist
  9. 0 {GMGridView → Example}/GMGridView-Prefix.pch
  10. +346 −0 Example/GMGridViewExample.xcodeproj/project.pbxproj
  11. 0 ...iew.xcodeproj → Example/GMGridViewExample.xcodeproj}/project.xcworkspace/contents.xcworkspacedata
  12. 0 {GMGridView → Example}/OptionsViewController.h
  13. +5 −0 {GMGridView → Example}/OptionsViewController.m
  14. 0 {GMGridView → Example}/Resources/close_x.png
  15. 0 {GMGridView → Example}/en.lproj/InfoPlist.strings
  16. 0 {GMGridView → Example}/main.m
  17. +0 −355 GMGridView.xcodeproj/project.pbxproj
  18. +1 −0 GMGridView/{API → }/GMGridView-Constants.h
  19. +41 −25 GMGridView/{API → }/GMGridView.h
  20. +474 −326 GMGridView/{API → }/GMGridView.m
  21. +284 −0 GMGridView/GMGridView.xcodeproj/project.pbxproj
  22. +3 −6 GMGridView/{API → }/GMGridViewCell+Extended.h
  23. +2 −3 GMGridView/{API → }/GMGridViewCell.h
  24. +33 −23 GMGridView/{API → }/GMGridViewCell.m
  25. 0 GMGridView/{API → }/GMGridViewLayoutStrategies.h
  26. +2 −2 GMGridView/{API → }/GMGridViewLayoutStrategies.m
  27. 0 GMGridView/{API → }/UIGestureRecognizer+GMGridViewAdditions.h
  28. 0 GMGridView/{API → }/UIGestureRecognizer+GMGridViewAdditions.m
  29. 0 GMGridView/{API → }/UIView+GMGridViewAdditions.h
  30. 0 GMGridView/{API → }/UIView+GMGridViewAdditions.m
  31. +0 −70 README
  32. +70 −0 README.md
View
1 .gitignore
@@ -6,3 +6,4 @@ xcuserdata/
*.xcodeproj/xcuserdata/
*.xcodeproj/project.xcworkspace/xcuserdata/
*.xcuserstate
+build
View
0 GMGridView/AppDelegate.h → Example/AppDelegate.h
File renamed without changes.
View
0 GMGridView/AppDelegate.m → Example/AppDelegate.m
File renamed without changes.
View
0 GMGridView/Demo1ViewController.h → Example/Demo1ViewController.h
File renamed without changes.
View
135 GMGridView/Demo1ViewController.m → Example/Demo1ViewController.m
@@ -12,6 +12,7 @@
#import "OptionsViewController.h"
#define NUMBER_ITEMS_ON_LOAD 250
+#define NUMBER_ITEMS_ON_LOAD2 30
//////////////////////////////////////////////////////////////
#pragma mark -
@@ -25,6 +26,9 @@ @interface Demo1ViewController () <GMGridViewDataSource, GMGridViewSortingDelega
UIPopoverController *_optionsPopOver;
NSMutableArray *_data;
+ NSMutableArray *_data2;
+ __gm_weak NSMutableArray *_currentData;
+ NSInteger _lastDeleteItemIndexAsked;
}
- (void)addMoreItem;
@@ -33,6 +37,7 @@ - (void)refreshItem;
- (void)presentInfo;
- (void)presentOptions:(UIBarButtonItem *)barButton;
- (void)optionsDoneAction;
+- (void)dataSetChange:(UISegmentedControl *)control;
@end
@@ -81,9 +86,17 @@ - (id)init
for (int i = 0; i < NUMBER_ITEMS_ON_LOAD; i ++)
{
- [_data addObject:[NSString stringWithFormat:@"%d", i]];
+ [_data addObject:[NSString stringWithFormat:@"A %d", i]];
}
+ _data2 = [[NSMutableArray alloc] init];
+
+ for (int i = 0; i < NUMBER_ITEMS_ON_LOAD2; i ++)
+ {
+ [_data2 addObject:[NSString stringWithFormat:@"B %d", i]];
+ }
+
+ _currentData = _data;
}
return self;
@@ -124,6 +137,18 @@ - (void)loadView
[infoButton addTarget:self action:@selector(presentInfo) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:infoButton];
+ UISegmentedControl *dataSegmentedControl = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObjects:@"DataSet 1", @"DataSet 2", nil]];
+ [dataSegmentedControl sizeToFit];
+ dataSegmentedControl.frame = CGRectMake(5,
+ self.view.bounds.size.height - dataSegmentedControl.bounds.size.height - 5,
+ dataSegmentedControl.bounds.size.width,
+ dataSegmentedControl.bounds.size.height);
+ dataSegmentedControl.autoresizingMask = UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleTopMargin;
+ dataSegmentedControl.tintColor = [UIColor greenColor];
+ dataSegmentedControl.selectedSegmentIndex = 0;
+ [dataSegmentedControl addTarget:self action:@selector(dataSetChange:) forControlEvents:UIControlEventValueChanged];
+ [self.view addSubview:dataSegmentedControl];
+
OptionsViewController *optionsController = [[OptionsViewController alloc] init];
optionsController.gridView = gmGridView;
@@ -179,18 +204,32 @@ - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interface
- (NSInteger)numberOfItemsInGMGridView:(GMGridView *)gridView
{
- return [_data count];
+ return [_currentData count];
}
-- (CGSize)sizeForItemsInGMGridView:(GMGridView *)gridView
+- (CGSize)GMGridView:(GMGridView *)gridView sizeForItemsInInterfaceOrientation:(UIInterfaceOrientation)orientation
{
if (INTERFACE_IS_PHONE)
{
- return CGSizeMake(140, 110);
+ if (UIInterfaceOrientationIsLandscape(orientation))
+ {
+ return CGSizeMake(170, 135);
+ }
+ else
+ {
+ return CGSizeMake(140, 110);
+ }
}
else
{
- return CGSizeMake(230, 175);
+ if (UIInterfaceOrientationIsLandscape(orientation))
+ {
+ return CGSizeMake(285, 205);
+ }
+ else
+ {
+ return CGSizeMake(230, 175);
+ }
}
}
@@ -198,7 +237,7 @@ - (GMGridViewCell *)GMGridView:(GMGridView *)gridView cellForItemAtIndex:(NSInte
{
//NSLog(@"Creating view indx %d", index);
- CGSize size = [self sizeForItemsInGMGridView:gridView];
+ CGSize size = [self GMGridView:gridView sizeForItemsInInterfaceOrientation:[[UIApplication sharedApplication] statusBarOrientation]];
GMGridViewCell *cell = [gridView dequeueReusableCell];
@@ -212,10 +251,6 @@ - (GMGridViewCell *)GMGridView:(GMGridView *)gridView cellForItemAtIndex:(NSInte
view.backgroundColor = [UIColor redColor];
view.layer.masksToBounds = NO;
view.layer.cornerRadius = 8;
- view.layer.shadowColor = [UIColor grayColor].CGColor;
- view.layer.shadowOffset = CGSizeMake(5, 5);
- view.layer.shadowPath = [UIBezierPath bezierPathWithRect:view.bounds].CGPath;
- view.layer.shadowRadius = 8;
cell.contentView = view;
}
@@ -224,7 +259,7 @@ - (GMGridViewCell *)GMGridView:(GMGridView *)gridView cellForItemAtIndex:(NSInte
UILabel *label = [[UILabel alloc] initWithFrame:cell.contentView.bounds];
label.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
- label.text = (NSString *)[_data objectAtIndex:index];
+ label.text = (NSString *)[_currentData objectAtIndex:index];
label.textAlignment = UITextAlignmentCenter;
label.backgroundColor = [UIColor clearColor];
label.textColor = [UIColor blackColor];
@@ -234,9 +269,10 @@ - (GMGridViewCell *)GMGridView:(GMGridView *)gridView cellForItemAtIndex:(NSInte
return cell;
}
-- (void)GMGridView:(GMGridView *)gridView deleteItemAtIndex:(NSInteger)index
+
+- (BOOL)GMGridView:(GMGridView *)gridView canDeleteItemAtIndex:(NSInteger)index
{
- [_data removeObjectAtIndex:index];
+ return YES; //index % 2 == 0;
}
//////////////////////////////////////////////////////////////
@@ -248,7 +284,23 @@ - (void)GMGridView:(GMGridView *)gridView didTapOnItemAtIndex:(NSInteger)positio
NSLog(@"Did tap at index %d", position);
}
+- (void)GMGridView:(GMGridView *)gridView processDeleteActionForItemAtIndex:(NSInteger)index
+{
+ UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Confirm" message:@"Are you sure you want to delete this item?" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Delete", nil];
+
+ [alert show];
+
+ _lastDeleteItemIndexAsked = index;
+}
+- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
+{
+ if (buttonIndex == 1)
+ {
+ [_currentData removeObjectAtIndex:_lastDeleteItemIndexAsked];
+ [_gmGridView removeObjectAtIndex:_lastDeleteItemIndexAsked withAnimation:GMGridViewItemAnimationFade];
+ }
+}
//////////////////////////////////////////////////////////////
#pragma mark GMGridViewSortingDelegate
@@ -287,14 +339,14 @@ - (BOOL)GMGridView:(GMGridView *)gridView shouldAllowShakingBehaviorWhenMovingCe
- (void)GMGridView:(GMGridView *)gridView moveItemAtIndex:(NSInteger)oldIndex toIndex:(NSInteger)newIndex
{
- NSObject *object = [_data objectAtIndex:oldIndex];
- [_data removeObject:object];
- [_data insertObject:object atIndex:newIndex];
+ NSObject *object = [_currentData objectAtIndex:oldIndex];
+ [_currentData removeObject:object];
+ [_currentData insertObject:object atIndex:newIndex];
}
- (void)GMGridView:(GMGridView *)gridView exchangeItemAtIndex:(NSInteger)index1 withItemAtIndex:(NSInteger)index2
{
- [_data exchangeObjectAtIndex:index1 withObjectAtIndex:index2];
+ [_currentData exchangeObjectAtIndex:index1 withObjectAtIndex:index2];
}
@@ -302,15 +354,29 @@ - (void)GMGridView:(GMGridView *)gridView exchangeItemAtIndex:(NSInteger)index1
#pragma mark DraggableGridViewTransformingDelegate
//////////////////////////////////////////////////////////////
-- (CGSize)GMGridView:(GMGridView *)gridView sizeInFullSizeForCell:(GMGridViewCell *)cell atIndex:(NSInteger)index
+- (CGSize)GMGridView:(GMGridView *)gridView sizeInFullSizeForCell:(GMGridViewCell *)cell atIndex:(NSInteger)index inInterfaceOrientation:(UIInterfaceOrientation)orientation
{
if (INTERFACE_IS_PHONE)
{
- return CGSizeMake(310, 310);
+ if (UIInterfaceOrientationIsLandscape(orientation))
+ {
+ return CGSizeMake(320, 210);
+ }
+ else
+ {
+ return CGSizeMake(300, 310);
+ }
}
else
{
- return CGSizeMake(700, 530);
+ if (UIInterfaceOrientationIsLandscape(orientation))
+ {
+ return CGSizeMake(700, 530);
+ }
+ else
+ {
+ return CGSizeMake(600, 500);
+ }
}
}
@@ -321,7 +387,7 @@ - (UIView *)GMGridView:(GMGridView *)gridView fullSizeViewForCell:(GMGridViewCel
fullView.layer.masksToBounds = NO;
fullView.layer.cornerRadius = 8;
- CGSize size = [self GMGridView:gridView sizeInFullSizeForCell:cell atIndex:index];
+ CGSize size = [self GMGridView:gridView sizeInFullSizeForCell:cell atIndex:index inInterfaceOrientation:[[UIApplication sharedApplication] statusBarOrientation]];
fullView.bounds = CGRectMake(0, 0, size.width, size.height);
UILabel *label = [[UILabel alloc] initWithFrame:fullView.bounds];
@@ -384,33 +450,33 @@ - (void)addMoreItem
// Example: adding object at the last position
NSString *newItem = [NSString stringWithFormat:@"%d", (int)(arc4random() % 1000)];
- [_data addObject:newItem];
- [_gmGridView insertObjectAtIndex:[_data count] - 1];
+ [_currentData addObject:newItem];
+ [_gmGridView insertObjectAtIndex:[_currentData count] - 1 withAnimation:GMGridViewItemAnimationFade | GMGridViewItemAnimationScroll];
}
- (void)removeItem
{
// Example: removing last item
- if ([_data count] > 0)
+ if ([_currentData count] > 0)
{
- NSInteger index = [_data count] - 1;
+ NSInteger index = [_currentData count] - 1;
- [_gmGridView removeObjectAtIndex:index];
- [_data removeObjectAtIndex:index];
+ [_gmGridView removeObjectAtIndex:index withAnimation:GMGridViewItemAnimationFade | GMGridViewItemAnimationScroll];
+ [_currentData removeObjectAtIndex:index];
}
}
- (void)refreshItem
{
// Example: reloading last item
- if ([_data count] > 0)
+ if ([_currentData count] > 0)
{
- int index = [_data count] - 1;
+ int index = [_currentData count] - 1;
NSString *newMessage = [NSString stringWithFormat:@"%d", (arc4random() % 1000)];
- [_data replaceObjectAtIndex:index withObject:newMessage];
- [_gmGridView reloadObjectAtIndex:index];
+ [_currentData replaceObjectAtIndex:index withObject:newMessage];
+ [_gmGridView reloadObjectAtIndex:index withAnimation:GMGridViewItemAnimationFade | GMGridViewItemAnimationScroll];
}
}
@@ -427,6 +493,13 @@ - (void)presentInfo
[alertView show];
}
+- (void)dataSetChange:(UISegmentedControl *)control
+{
+ _currentData = ([control selectedSegmentIndex] == 0) ? _data : _data2;
+
+ [_gmGridView reloadData];
+}
+
- (void)presentOptions:(UIBarButtonItem *)barButton
{
if (INTERFACE_IS_PHONE)
View
0 GMGridView/Demo2ViewController.h → Example/Demo2ViewController.h
File renamed without changes.
View
25 GMGridView/Demo2ViewController.m → Example/Demo2ViewController.m
@@ -115,8 +115,8 @@ - (void)viewDidLoad
_gmGridView2.transformDelegate = self;
_gmGridView2.dataSource = self;
- _gmGridView1.mainSuperView = self.navigationController.view;
- _gmGridView2.mainSuperView = self.navigationController.view;
+ _gmGridView1.mainSuperView = self.view;
+ _gmGridView2.mainSuperView = self.view;
OptionsViewController *optionsController = [[OptionsViewController alloc] init];
@@ -164,7 +164,8 @@ - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interface
- (void)computeViewFrames
{
- CGSize itemSize = [self sizeForItemsInGMGridView:_gmGridView1];
+ CGSize itemSize = [self GMGridView:_gmGridView1 sizeForItemsInInterfaceOrientation:[[UIApplication sharedApplication] statusBarOrientation]];
+
CGSize minSize = CGSizeMake(itemSize.width + _gmGridView1.minEdgeInsets.right + _gmGridView1.minEdgeInsets.left,
itemSize.height + _gmGridView1.minEdgeInsets.top + _gmGridView1.minEdgeInsets.bottom);
@@ -232,7 +233,7 @@ - (NSInteger)numberOfItemsInGMGridView:(GMGridView *)gridView
return 50;
}
-- (CGSize)sizeForItemsInGMGridView:(GMGridView *)gridView
+- (CGSize)GMGridView:(GMGridView *)gridView sizeForItemsInInterfaceOrientation:(UIInterfaceOrientation)orientation
{
if (INTERFACE_IS_PHONE)
{
@@ -246,7 +247,7 @@ - (CGSize)sizeForItemsInGMGridView:(GMGridView *)gridView
- (GMGridViewCell *)GMGridView:(GMGridView *)gridView cellForItemAtIndex:(NSInteger)index
{
- CGSize size = [self sizeForItemsInGMGridView:gridView];
+ CGSize size = [self GMGridView:gridView sizeForItemsInInterfaceOrientation:[[UIApplication sharedApplication] statusBarOrientation]];
GMGridViewCell *cell = [gridView dequeueReusableCell];
@@ -331,16 +332,10 @@ - (void)GMGridView:(GMGridView *)gridView exchangeItemAtIndex:(NSInteger)index1
#pragma mark DraggableGridViewTransformingDelegate
//////////////////////////////////////////////////////////////
-- (CGSize)GMGridView:(GMGridView *)gridView sizeInFullSizeForCell:(GMGridViewCell *)cell atIndex:(NSInteger)index
+- (CGSize)GMGridView:(GMGridView *)gridView sizeInFullSizeForCell:(GMGridViewCell *)cell atIndex:(NSInteger)index inInterfaceOrientation:(UIInterfaceOrientation)orientation
{
- if (INTERFACE_IS_PHONE)
- {
- return CGSizeMake(310, 310);
- }
- else
- {
- return CGSizeMake(700, 530);
- }
+ CGSize viewSize = self.view.bounds.size;
+ return CGSizeMake(viewSize.width - 50, viewSize.height - 50);
}
- (UIView *)GMGridView:(GMGridView *)gridView fullSizeViewForCell:(GMGridViewCell *)cell atIndex:(NSInteger)index
@@ -350,7 +345,7 @@ - (UIView *)GMGridView:(GMGridView *)gridView fullSizeViewForCell:(GMGridViewCel
fullView.layer.masksToBounds = NO;
fullView.layer.cornerRadius = 8;
- CGSize size = [self GMGridView:gridView sizeInFullSizeForCell:cell atIndex:index];
+ CGSize size = [self GMGridView:gridView sizeInFullSizeForCell:cell atIndex:index inInterfaceOrientation:[[UIApplication sharedApplication] statusBarOrientation]];
fullView.bounds = CGRectMake(0, 0, size.width, size.height);
UILabel *label = [[UILabel alloc] initWithFrame:fullView.bounds];
View
0 GMGridView/GMGridView-Info.plist → Example/GMGridView-Info.plist
File renamed without changes.
View
0 GMGridView/GMGridView-Prefix.pch → Example/GMGridView-Prefix.pch
File renamed without changes.
View
346 Example/GMGridViewExample.xcodeproj/project.pbxproj
@@ -0,0 +1,346 @@
+// !$*UTF8*$!
+{
+ archiveVersion = 1;
+ classes = {
+ };
+ objectVersion = 46;
+ objects = {
+
+/* Begin PBXBuildFile section */
+ 16275EF2144D26C10041AF02 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 16275EF1144D26C10041AF02 /* QuartzCore.framework */; };
+ 16924B0C144156FE00E6E556 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 16924B0B144156FE00E6E556 /* UIKit.framework */; };
+ 16924B0E144156FE00E6E556 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 16924B0D144156FE00E6E556 /* Foundation.framework */; };
+ 16924B10144156FE00E6E556 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 16924B0F144156FE00E6E556 /* CoreGraphics.framework */; };
+ 785092D4149FABAC000787E4 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 785092CF149FABAC000787E4 /* AppDelegate.m */; };
+ 785092D5149FABAC000787E4 /* Demo1ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 785092D1149FABAC000787E4 /* Demo1ViewController.m */; };
+ 785092D6149FABAC000787E4 /* Demo2ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 785092D3149FABAC000787E4 /* Demo2ViewController.m */; };
+ 785092DB149FABB6000787E4 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 785092D9149FABB6000787E4 /* main.m */; };
+ 78509333149FAC52000787E4 /* libGMGridView.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 78509330149FAC48000787E4 /* libGMGridView.a */; };
+ 78509354149FAC81000787E4 /* close_x.png in Resources */ = {isa = PBXBuildFile; fileRef = 78509353149FAC81000787E4 /* close_x.png */; };
+ 7850936A149FADB4000787E4 /* OptionsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 78509369149FADB4000787E4 /* OptionsViewController.m */; };
+/* End PBXBuildFile section */
+
+/* Begin PBXContainerItemProxy section */
+ 7850932F149FAC48000787E4 /* PBXContainerItemProxy */ = {
+ isa = PBXContainerItemProxy;
+ containerPortal = 78509328149FAC48000787E4 /* GMGridView.xcodeproj */;
+ proxyType = 2;
+ remoteGlobalIDString = 78509312149FAC2E000787E4;
+ remoteInfo = GMGridView;
+ };
+ 78509331149FAC4F000787E4 /* PBXContainerItemProxy */ = {
+ isa = PBXContainerItemProxy;
+ containerPortal = 78509328149FAC48000787E4 /* GMGridView.xcodeproj */;
+ proxyType = 1;
+ remoteGlobalIDString = 78509311149FAC2E000787E4;
+ remoteInfo = GMGridView;
+ };
+/* End PBXContainerItemProxy section */
+
+/* Begin PBXFileReference section */
+ 16275EF1144D26C10041AF02 /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; };
+ 16924B07144156FE00E6E556 /* GMGridView.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = GMGridView.app; sourceTree = BUILT_PRODUCTS_DIR; };
+ 16924B0B144156FE00E6E556 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
+ 16924B0D144156FE00E6E556 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
+ 16924B0F144156FE00E6E556 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
+ 785092CE149FABAC000787E4 /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = SOURCE_ROOT; };
+ 785092CF149FABAC000787E4 /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = SOURCE_ROOT; };
+ 785092D0149FABAC000787E4 /* Demo1ViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Demo1ViewController.h; sourceTree = SOURCE_ROOT; };
+ 785092D1149FABAC000787E4 /* Demo1ViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Demo1ViewController.m; sourceTree = SOURCE_ROOT; };
+ 785092D2149FABAC000787E4 /* Demo2ViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Demo2ViewController.h; sourceTree = SOURCE_ROOT; };
+ 785092D3149FABAC000787E4 /* Demo2ViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Demo2ViewController.m; sourceTree = SOURCE_ROOT; };
+ 785092D7149FABB6000787E4 /* GMGridView-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "GMGridView-Info.plist"; sourceTree = SOURCE_ROOT; };
+ 785092D8149FABB6000787E4 /* GMGridView-Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "GMGridView-Prefix.pch"; sourceTree = SOURCE_ROOT; };
+ 785092D9149FABB6000787E4 /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = SOURCE_ROOT; };
+ 78509328149FAC48000787E4 /* GMGridView.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = GMGridView.xcodeproj; path = ../GMGridView/GMGridView.xcodeproj; sourceTree = "<group>"; };
+ 78509353149FAC81000787E4 /* close_x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = close_x.png; path = Resources/close_x.png; sourceTree = SOURCE_ROOT; };
+ 78509368149FADB4000787E4 /* OptionsViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OptionsViewController.h; sourceTree = SOURCE_ROOT; };
+ 78509369149FADB4000787E4 /* OptionsViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OptionsViewController.m; sourceTree = SOURCE_ROOT; };
+/* End PBXFileReference section */
+
+/* Begin PBXFrameworksBuildPhase section */
+ 16924B04144156FE00E6E556 /* Frameworks */ = {
+ isa = PBXFrameworksBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 78509333149FAC52000787E4 /* libGMGridView.a in Frameworks */,
+ 16275EF2144D26C10041AF02 /* QuartzCore.framework in Frameworks */,
+ 16924B0C144156FE00E6E556 /* UIKit.framework in Frameworks */,
+ 16924B0E144156FE00E6E556 /* Foundation.framework in Frameworks */,
+ 16924B10144156FE00E6E556 /* CoreGraphics.framework in Frameworks */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXFrameworksBuildPhase section */
+
+/* Begin PBXGroup section */
+ 16924AFC144156FD00E6E556 = {
+ isa = PBXGroup;
+ children = (
+ 16924B11144156FE00E6E556 /* Demo */,
+ 16955520146FA80200DECCA6 /* Resources */,
+ 16924B0A144156FE00E6E556 /* Frameworks */,
+ 16924B08144156FE00E6E556 /* Products */,
+ );
+ sourceTree = "<group>";
+ };
+ 16924B08144156FE00E6E556 /* Products */ = {
+ isa = PBXGroup;
+ children = (
+ 16924B07144156FE00E6E556 /* GMGridView.app */,
+ );
+ name = Products;
+ sourceTree = "<group>";
+ };
+ 16924B0A144156FE00E6E556 /* Frameworks */ = {
+ isa = PBXGroup;
+ children = (
+ 78509328149FAC48000787E4 /* GMGridView.xcodeproj */,
+ 16275EF1144D26C10041AF02 /* QuartzCore.framework */,
+ 16924B0B144156FE00E6E556 /* UIKit.framework */,
+ 16924B0D144156FE00E6E556 /* Foundation.framework */,
+ 16924B0F144156FE00E6E556 /* CoreGraphics.framework */,
+ );
+ name = Frameworks;
+ sourceTree = "<group>";
+ };
+ 16924B11144156FE00E6E556 /* Demo */ = {
+ isa = PBXGroup;
+ children = (
+ 785092CE149FABAC000787E4 /* AppDelegate.h */,
+ 785092CF149FABAC000787E4 /* AppDelegate.m */,
+ 785092D0149FABAC000787E4 /* Demo1ViewController.h */,
+ 785092D1149FABAC000787E4 /* Demo1ViewController.m */,
+ 785092D2149FABAC000787E4 /* Demo2ViewController.h */,
+ 785092D3149FABAC000787E4 /* Demo2ViewController.m */,
+ 78509368149FADB4000787E4 /* OptionsViewController.h */,
+ 78509369149FADB4000787E4 /* OptionsViewController.m */,
+ 16924B12144156FE00E6E556 /* Supporting Files */,
+ );
+ name = Demo;
+ path = DraggableGridView;
+ sourceTree = "<group>";
+ };
+ 16924B12144156FE00E6E556 /* Supporting Files */ = {
+ isa = PBXGroup;
+ children = (
+ 785092D7149FABB6000787E4 /* GMGridView-Info.plist */,
+ 785092D8149FABB6000787E4 /* GMGridView-Prefix.pch */,
+ 785092D9149FABB6000787E4 /* main.m */,
+ );
+ name = "Supporting Files";
+ sourceTree = "<group>";
+ };
+ 16955520146FA80200DECCA6 /* Resources */ = {
+ isa = PBXGroup;
+ children = (
+ 78509353149FAC81000787E4 /* close_x.png */,
+ );
+ name = Resources;
+ path = GMGridView/Resources;
+ sourceTree = "<group>";
+ };
+ 78509329149FAC48000787E4 /* Products */ = {
+ isa = PBXGroup;
+ children = (
+ 78509330149FAC48000787E4 /* libGMGridView.a */,
+ );
+ name = Products;
+ sourceTree = "<group>";
+ };
+/* End PBXGroup section */
+
+/* Begin PBXNativeTarget section */
+ 16924B06144156FE00E6E556 /* GMGridViewExample */ = {
+ isa = PBXNativeTarget;
+ buildConfigurationList = 16924B28144156FE00E6E556 /* Build configuration list for PBXNativeTarget "GMGridViewExample" */;
+ buildPhases = (
+ 16924B03144156FE00E6E556 /* Sources */,
+ 16924B04144156FE00E6E556 /* Frameworks */,
+ 16924B05144156FE00E6E556 /* Resources */,
+ );
+ buildRules = (
+ );
+ dependencies = (
+ 78509332149FAC4F000787E4 /* PBXTargetDependency */,
+ );
+ name = GMGridViewExample;
+ productName = DraggableGridView;
+ productReference = 16924B07144156FE00E6E556 /* GMGridView.app */;
+ productType = "com.apple.product-type.application";
+ };
+/* End PBXNativeTarget section */
+
+/* Begin PBXProject section */
+ 16924AFE144156FD00E6E556 /* Project object */ = {
+ isa = PBXProject;
+ attributes = {
+ LastUpgradeCheck = 0420;
+ ORGANIZATIONNAME = GMoledina.ca;
+ };
+ buildConfigurationList = 16924B01144156FD00E6E556 /* Build configuration list for PBXProject "GMGridViewExample" */;
+ compatibilityVersion = "Xcode 3.2";
+ developmentRegion = English;
+ hasScannedForEncodings = 0;
+ knownRegions = (
+ en,
+ );
+ mainGroup = 16924AFC144156FD00E6E556;
+ productRefGroup = 16924B08144156FE00E6E556 /* Products */;
+ projectDirPath = "";
+ projectReferences = (
+ {
+ ProductGroup = 78509329149FAC48000787E4 /* Products */;
+ ProjectRef = 78509328149FAC48000787E4 /* GMGridView.xcodeproj */;
+ },
+ );
+ projectRoot = "";
+ targets = (
+ 16924B06144156FE00E6E556 /* GMGridViewExample */,
+ );
+ };
+/* End PBXProject section */
+
+/* Begin PBXReferenceProxy section */
+ 78509330149FAC48000787E4 /* libGMGridView.a */ = {
+ isa = PBXReferenceProxy;
+ fileType = archive.ar;
+ path = libGMGridView.a;
+ remoteRef = 7850932F149FAC48000787E4 /* PBXContainerItemProxy */;
+ sourceTree = BUILT_PRODUCTS_DIR;
+ };
+/* End PBXReferenceProxy section */
+
+/* Begin PBXResourcesBuildPhase section */
+ 16924B05144156FE00E6E556 /* Resources */ = {
+ isa = PBXResourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 78509354149FAC81000787E4 /* close_x.png in Resources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXResourcesBuildPhase section */
+
+/* Begin PBXSourcesBuildPhase section */
+ 16924B03144156FE00E6E556 /* Sources */ = {
+ isa = PBXSourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 785092D4149FABAC000787E4 /* AppDelegate.m in Sources */,
+ 785092D5149FABAC000787E4 /* Demo1ViewController.m in Sources */,
+ 785092D6149FABAC000787E4 /* Demo2ViewController.m in Sources */,
+ 785092DB149FABB6000787E4 /* main.m in Sources */,
+ 7850936A149FADB4000787E4 /* OptionsViewController.m in Sources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXSourcesBuildPhase section */
+
+/* Begin PBXTargetDependency section */
+ 78509332149FAC4F000787E4 /* PBXTargetDependency */ = {
+ isa = PBXTargetDependency;
+ name = GMGridView;
+ targetProxy = 78509331149FAC4F000787E4 /* PBXContainerItemProxy */;
+ };
+/* End PBXTargetDependency section */
+
+/* Begin XCBuildConfiguration section */
+ 16924B26144156FE00E6E556 /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ ARCHS = "$(ARCHS_STANDARD_32_BIT)";
+ CLANG_ENABLE_OBJC_ARC = YES;
+ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
+ 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_VERSION = com.apple.compilers.llvm.clang.1_0;
+ GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES;
+ GCC_WARN_ABOUT_RETURN_TYPE = YES;
+ GCC_WARN_UNUSED_VARIABLE = YES;
+ HEADER_SEARCH_PATHS = "../GMGridView/**";
+ IPHONEOS_DEPLOYMENT_TARGET = 4.2;
+ OTHER_LDFLAGS = "-ObjC";
+ SDKROOT = iphoneos;
+ TARGETED_DEVICE_FAMILY = "1,2";
+ };
+ name = Debug;
+ };
+ 16924B27144156FE00E6E556 /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ ARCHS = "$(ARCHS_STANDARD_32_BIT)";
+ CLANG_ENABLE_OBJC_ARC = YES;
+ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
+ COPY_PHASE_STRIP = YES;
+ GCC_C_LANGUAGE_STANDARD = gnu99;
+ GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
+ GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES;
+ GCC_WARN_ABOUT_RETURN_TYPE = YES;
+ GCC_WARN_UNUSED_VARIABLE = YES;
+ HEADER_SEARCH_PATHS = "../GMGridView/**";
+ IPHONEOS_DEPLOYMENT_TARGET = 4.2;
+ OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1";
+ OTHER_LDFLAGS = "-ObjC";
+ SDKROOT = iphoneos;
+ TARGETED_DEVICE_FAMILY = "1,2";
+ VALIDATE_PRODUCT = YES;
+ };
+ name = Release;
+ };
+ 16924B29144156FE00E6E556 /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ GCC_PRECOMPILE_PREFIX_HEADER = YES;
+ GCC_PREFIX_HEADER = "GMGridView-Prefix.pch";
+ INFOPLIST_FILE = "GMGridView-Info.plist";
+ PRODUCT_NAME = GMGridView;
+ WRAPPER_EXTENSION = app;
+ };
+ name = Debug;
+ };
+ 16924B2A144156FE00E6E556 /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ GCC_PRECOMPILE_PREFIX_HEADER = YES;
+ GCC_PREFIX_HEADER = "GMGridView-Prefix.pch";
+ INFOPLIST_FILE = "GMGridView-Info.plist";
+ PRODUCT_NAME = GMGridView;
+ WRAPPER_EXTENSION = app;
+ };
+ name = Release;
+ };
+/* End XCBuildConfiguration section */
+
+/* Begin XCConfigurationList section */
+ 16924B01144156FD00E6E556 /* Build configuration list for PBXProject "GMGridViewExample" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ 16924B26144156FE00E6E556 /* Debug */,
+ 16924B27144156FE00E6E556 /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+ 16924B28144156FE00E6E556 /* Build configuration list for PBXNativeTarget "GMGridViewExample" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ 16924B29144156FE00E6E556 /* Debug */,
+ 16924B2A144156FE00E6E556 /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+/* End XCConfigurationList section */
+ };
+ rootObject = 16924AFE144156FD00E6E556 /* Project object */;
+}
View
0 ...ject.xcworkspace/contents.xcworkspacedata → ...ject.xcworkspace/contents.xcworkspacedata
File renamed without changes.
View
0 GMGridView/OptionsViewController.h → Example/OptionsViewController.h
File renamed without changes.
View
5 GMGridView/OptionsViewController.m → Example/OptionsViewController.m
@@ -391,6 +391,7 @@ - (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComp
self.gridView.layoutStrategy = [GMGridViewLayoutStrategyFactory strategyFromType:GMGridViewLayoutVertical];
break;
}
+ [self.gridView layoutSubviewsWithAnimation:GMGridViewItemAnimationFade];
}
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView
@@ -436,6 +437,7 @@ - (void)editingSwitchChanged:(UISwitch *)control
{
self.gridView.editing = control.on;
control.on = self.gridView.isEditing;
+ [self.gridView layoutSubviewsWithAnimation:GMGridViewItemAnimationFade];
}
- (void)sortStyleSegmentedControlChanged:(UISegmentedControl *)control
@@ -455,16 +457,19 @@ - (void)sortStyleSegmentedControlChanged:(UISegmentedControl *)control
- (void)layoutCenterSwitchChanged:(UISwitch *)control
{
self.gridView.centerGrid = control.on;
+ [self.gridView layoutSubviewsWithAnimation:GMGridViewItemAnimationFade];
}
- (void)layoutSpacingSliderChanged:(UISlider *)control
{
self.gridView.itemSpacing = control.value;
+ [self.gridView layoutSubviewsWithAnimation:GMGridViewItemAnimationFade];
}
- (void)layoutInsetsSliderChanged:(UISlider *)control
{
self.gridView.minEdgeInsets = UIEdgeInsetsMake(control.value, control.value, control.value, control.value);
+ [self.gridView layoutSubviewsWithAnimation:GMGridViewItemAnimationFade];
}
- (void)debugGridBackgroundSwitchChanged:(UISwitch *)control
View
0 GMGridView/Resources/close_x.png → Example/Resources/close_x.png
File renamed without changes
View
0 GMGridView/en.lproj/InfoPlist.strings → Example/en.lproj/InfoPlist.strings
File renamed without changes.
View
0 GMGridView/main.m → Example/main.m
File renamed without changes.
View
355 GMGridView.xcodeproj/project.pbxproj
@@ -1,355 +0,0 @@
-// !$*UTF8*$!
-{
- archiveVersion = 1;
- classes = {
- };
- objectVersion = 46;
- objects = {
-
-/* Begin PBXBuildFile section */
- 16026C0E1454628800093AFF /* UIView+GMGridViewAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 16026C0D1454628800093AFF /* UIView+GMGridViewAdditions.m */; };
- 16026C131454631600093AFF /* LICENSE in Resources */ = {isa = PBXBuildFile; fileRef = 16026C111454631600093AFF /* LICENSE */; };
- 16026C141454631600093AFF /* README in Resources */ = {isa = PBXBuildFile; fileRef = 16026C121454631600093AFF /* README */; };
- 16275EF2144D26C10041AF02 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 16275EF1144D26C10041AF02 /* QuartzCore.framework */; };
- 16583C24146CC2290006F11B /* Demo2ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 16583C23146CC2290006F11B /* Demo2ViewController.m */; };
- 1691D7A41442CFC300F472BF /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 1691D7A31442CFC300F472BF /* main.m */; };
- 1691D7AA1442D01F00F472BF /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 1691D7A71442D01F00F472BF /* AppDelegate.m */; };
- 1691D7AB1442D01F00F472BF /* Demo1ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 1691D7A91442D01F00F472BF /* Demo1ViewController.m */; };
- 1691D7AE1442D02C00F472BF /* GMGridView.m in Sources */ = {isa = PBXBuildFile; fileRef = 1691D7AD1442D02C00F472BF /* GMGridView.m */; };
- 16924B0C144156FE00E6E556 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 16924B0B144156FE00E6E556 /* UIKit.framework */; };
- 16924B0E144156FE00E6E556 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 16924B0D144156FE00E6E556 /* Foundation.framework */; };
- 16924B10144156FE00E6E556 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 16924B0F144156FE00E6E556 /* CoreGraphics.framework */; };
- 16955523146FA81800DECCA6 /* close_x.png in Resources */ = {isa = PBXBuildFile; fileRef = 16955522146FA81800DECCA6 /* close_x.png */; };
- 169AE3781460E1B300C0CBCD /* OptionsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 169AE3771460E1B300C0CBCD /* OptionsViewController.m */; };
- 16A0D030145342F8004D7BBC /* GMGridViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 16A0D02F145342F8004D7BBC /* GMGridViewCell.m */; };
- 16DF1A6E145E3456006AA43C /* GMGridViewLayoutStrategies.m in Sources */ = {isa = PBXBuildFile; fileRef = 16DF1A6D145E3456006AA43C /* GMGridViewLayoutStrategies.m */; };
- 16DF1A71145E3461006AA43C /* UIGestureRecognizer+GMGridViewAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 16DF1A70145E3460006AA43C /* UIGestureRecognizer+GMGridViewAdditions.m */; };
-/* End PBXBuildFile section */
-
-/* Begin PBXFileReference section */
- 16026C0C1454628800093AFF /* UIView+GMGridViewAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "UIView+GMGridViewAdditions.h"; path = "GMGridView/API/UIView+GMGridViewAdditions.h"; sourceTree = SOURCE_ROOT; };
- 16026C0D1454628800093AFF /* UIView+GMGridViewAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "UIView+GMGridViewAdditions.m"; path = "GMGridView/API/UIView+GMGridViewAdditions.m"; sourceTree = SOURCE_ROOT; };
- 16026C111454631600093AFF /* LICENSE */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = LICENSE; sourceTree = "<group>"; };
- 16026C121454631600093AFF /* README */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = README; sourceTree = "<group>"; };
- 16275EF1144D26C10041AF02 /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; };
- 16583C22146CC2290006F11B /* Demo2ViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Demo2ViewController.h; path = GMGridView/Demo2ViewController.h; sourceTree = SOURCE_ROOT; };
- 16583C23146CC2290006F11B /* Demo2ViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = Demo2ViewController.m; path = GMGridView/Demo2ViewController.m; sourceTree = SOURCE_ROOT; };
- 1691D7A01442CFA800F472BF /* GMGridView-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = "GMGridView-Info.plist"; path = "GMGridView/GMGridView-Info.plist"; sourceTree = SOURCE_ROOT; };
- 1691D7A21442CFC300F472BF /* GMGridView-Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "GMGridView-Prefix.pch"; path = "GMGridView/GMGridView-Prefix.pch"; sourceTree = SOURCE_ROOT; };
- 1691D7A31442CFC300F472BF /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = main.m; path = GMGridView/main.m; sourceTree = SOURCE_ROOT; };
- 1691D7A61442D01F00F472BF /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AppDelegate.h; path = GMGridView/AppDelegate.h; sourceTree = SOURCE_ROOT; };
- 1691D7A71442D01F00F472BF /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AppDelegate.m; path = GMGridView/AppDelegate.m; sourceTree = SOURCE_ROOT; };
- 1691D7A81442D01F00F472BF /* Demo1ViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Demo1ViewController.h; path = GMGridView/Demo1ViewController.h; sourceTree = SOURCE_ROOT; };
- 1691D7A91442D01F00F472BF /* Demo1ViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = Demo1ViewController.m; path = GMGridView/Demo1ViewController.m; sourceTree = SOURCE_ROOT; };
- 1691D7AC1442D02C00F472BF /* GMGridView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GMGridView.h; path = GMGridView/API/GMGridView.h; sourceTree = SOURCE_ROOT; };
- 1691D7AD1442D02C00F472BF /* GMGridView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; name = GMGridView.m; path = GMGridView/API/GMGridView.m; sourceTree = SOURCE_ROOT; xcLanguageSpecificationIdentifier = xcode.lang.objc; };
- 16924B07144156FE00E6E556 /* GMGridView.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = GMGridView.app; sourceTree = BUILT_PRODUCTS_DIR; };
- 16924B0B144156FE00E6E556 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
- 16924B0D144156FE00E6E556 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
- 16924B0F144156FE00E6E556 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
- 16955522146FA81800DECCA6 /* close_x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = close_x.png; sourceTree = "<group>"; };
- 16961E1A14705B9B00DA708A /* GMGridViewCell+Extended.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "GMGridViewCell+Extended.h"; path = "GMGridView/API/GMGridViewCell+Extended.h"; sourceTree = SOURCE_ROOT; };
- 169AE3761460E1B300C0CBCD /* OptionsViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OptionsViewController.h; path = GMGridView/OptionsViewController.h; sourceTree = SOURCE_ROOT; };
- 169AE3771460E1B300C0CBCD /* OptionsViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OptionsViewController.m; path = GMGridView/OptionsViewController.m; sourceTree = SOURCE_ROOT; };
- 16A0D02E145342F8004D7BBC /* GMGridViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GMGridViewCell.h; path = GMGridView/API/GMGridViewCell.h; sourceTree = SOURCE_ROOT; };
- 16A0D02F145342F8004D7BBC /* GMGridViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = GMGridViewCell.m; path = GMGridView/API/GMGridViewCell.m; sourceTree = SOURCE_ROOT; };
- 16B3E6FA1499AB0000318848 /* GMGridView-Constants.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "GMGridView-Constants.h"; path = "GMGridView/API/GMGridView-Constants.h"; sourceTree = SOURCE_ROOT; };
- 16DF1A6C145E3456006AA43C /* GMGridViewLayoutStrategies.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GMGridViewLayoutStrategies.h; path = GMGridView/API/GMGridViewLayoutStrategies.h; sourceTree = SOURCE_ROOT; };
- 16DF1A6D145E3456006AA43C /* GMGridViewLayoutStrategies.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = GMGridViewLayoutStrategies.m; path = GMGridView/API/GMGridViewLayoutStrategies.m; sourceTree = SOURCE_ROOT; };
- 16DF1A6F145E3460006AA43C /* UIGestureRecognizer+GMGridViewAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "UIGestureRecognizer+GMGridViewAdditions.h"; path = "GMGridView/API/UIGestureRecognizer+GMGridViewAdditions.h"; sourceTree = SOURCE_ROOT; };
- 16DF1A70145E3460006AA43C /* UIGestureRecognizer+GMGridViewAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "UIGestureRecognizer+GMGridViewAdditions.m"; path = "GMGridView/API/UIGestureRecognizer+GMGridViewAdditions.m"; sourceTree = SOURCE_ROOT; };
-/* End PBXFileReference section */
-
-/* Begin PBXFrameworksBuildPhase section */
- 16924B04144156FE00E6E556 /* Frameworks */ = {
- isa = PBXFrameworksBuildPhase;
- buildActionMask = 2147483647;
- files = (
- 16275EF2144D26C10041AF02 /* QuartzCore.framework in Frameworks */,
- 16924B0C144156FE00E6E556 /* UIKit.framework in Frameworks */,
- 16924B0E144156FE00E6E556 /* Foundation.framework in Frameworks */,
- 16924B10144156FE00E6E556 /* CoreGraphics.framework in Frameworks */,
- );
- runOnlyForDeploymentPostprocessing = 0;
- };
-/* End PBXFrameworksBuildPhase section */
-
-/* Begin PBXGroup section */
- 16026C10145462EC00093AFF /* Documentation */ = {
- isa = PBXGroup;
- children = (
- 16026C111454631600093AFF /* LICENSE */,
- 16026C121454631600093AFF /* README */,
- );
- name = Documentation;
- sourceTree = "<group>";
- };
- 16924AFC144156FD00E6E556 = {
- isa = PBXGroup;
- children = (
- 16924B11144156FE00E6E556 /* Demo */,
- 16924B361442CA9400E6E556 /* API */,
- 16955520146FA80200DECCA6 /* Resources */,
- 16026C10145462EC00093AFF /* Documentation */,
- 16924B0A144156FE00E6E556 /* Frameworks */,
- 16924B08144156FE00E6E556 /* Products */,
- );
- sourceTree = "<group>";
- };
- 16924B08144156FE00E6E556 /* Products */ = {
- isa = PBXGroup;
- children = (
- 16924B07144156FE00E6E556 /* GMGridView.app */,
- );
- name = Products;
- sourceTree = "<group>";
- };
- 16924B0A144156FE00E6E556 /* Frameworks */ = {
- isa = PBXGroup;
- children = (
- 16275EF1144D26C10041AF02 /* QuartzCore.framework */,
- 16924B0B144156FE00E6E556 /* UIKit.framework */,
- 16924B0D144156FE00E6E556 /* Foundation.framework */,
- 16924B0F144156FE00E6E556 /* CoreGraphics.framework */,
- );
- name = Frameworks;
- sourceTree = "<group>";
- };
- 16924B11144156FE00E6E556 /* Demo */ = {
- isa = PBXGroup;
- children = (
- 1691D7A61442D01F00F472BF /* AppDelegate.h */,
- 1691D7A71442D01F00F472BF /* AppDelegate.m */,
- 1691D7A81442D01F00F472BF /* Demo1ViewController.h */,
- 1691D7A91442D01F00F472BF /* Demo1ViewController.m */,
- 16583C22146CC2290006F11B /* Demo2ViewController.h */,
- 16583C23146CC2290006F11B /* Demo2ViewController.m */,
- 169AE3761460E1B300C0CBCD /* OptionsViewController.h */,
- 169AE3771460E1B300C0CBCD /* OptionsViewController.m */,
- 16924B12144156FE00E6E556 /* Supporting Files */,
- );
- name = Demo;
- path = DraggableGridView;
- sourceTree = "<group>";
- };
- 16924B12144156FE00E6E556 /* Supporting Files */ = {
- isa = PBXGroup;
- children = (
- 1691D7A01442CFA800F472BF /* GMGridView-Info.plist */,
- 1691D7A21442CFC300F472BF /* GMGridView-Prefix.pch */,
- 1691D7A31442CFC300F472BF /* main.m */,
- );
- name = "Supporting Files";
- sourceTree = "<group>";
- };
- 16924B361442CA9400E6E556 /* API */ = {
- isa = PBXGroup;
- children = (
- 1691D7AC1442D02C00F472BF /* GMGridView.h */,
- 16A0D02E145342F8004D7BBC /* GMGridViewCell.h */,
- 16961E1C1470A61C00DA708A /* Implementation Logic */,
- );
- name = API;
- path = DraggableGridView/API;
- sourceTree = "<group>";
- };
- 16955520146FA80200DECCA6 /* Resources */ = {
- isa = PBXGroup;
- children = (
- 16955522146FA81800DECCA6 /* close_x.png */,
- );
- name = Resources;
- path = GMGridView/Resources;
- sourceTree = "<group>";
- };
- 16961E1C1470A61C00DA708A /* Implementation Logic */ = {
- isa = PBXGroup;
- children = (
- 16B3E6FA1499AB0000318848 /* GMGridView-Constants.h */,
- 1691D7AD1442D02C00F472BF /* GMGridView.m */,
- 16961E1A14705B9B00DA708A /* GMGridViewCell+Extended.h */,
- 16A0D02F145342F8004D7BBC /* GMGridViewCell.m */,
- 16DF1A6C145E3456006AA43C /* GMGridViewLayoutStrategies.h */,
- 16DF1A6D145E3456006AA43C /* GMGridViewLayoutStrategies.m */,
- 16026C0C1454628800093AFF /* UIView+GMGridViewAdditions.h */,
- 16026C0D1454628800093AFF /* UIView+GMGridViewAdditions.m */,
- 16DF1A6F145E3460006AA43C /* UIGestureRecognizer+GMGridViewAdditions.h */,
- 16DF1A70145E3460006AA43C /* UIGestureRecognizer+GMGridViewAdditions.m */,
- );
- name = "Implementation Logic";
- sourceTree = "<group>";
- };
-/* End PBXGroup section */
-
-/* Begin PBXNativeTarget section */
- 16924B06144156FE00E6E556 /* GMGridView */ = {
- isa = PBXNativeTarget;
- buildConfigurationList = 16924B28144156FE00E6E556 /* Build configuration list for PBXNativeTarget "GMGridView" */;
- buildPhases = (
- 16924B03144156FE00E6E556 /* Sources */,
- 16924B04144156FE00E6E556 /* Frameworks */,
- 16924B05144156FE00E6E556 /* Resources */,
- );
- buildRules = (
- );
- dependencies = (
- );
- name = GMGridView;
- productName = DraggableGridView;
- productReference = 16924B07144156FE00E6E556 /* GMGridView.app */;
- productType = "com.apple.product-type.application";
- };
-/* End PBXNativeTarget section */
-
-/* Begin PBXProject section */
- 16924AFE144156FD00E6E556 /* Project object */ = {
- isa = PBXProject;
- attributes = {
- LastUpgradeCheck = 0420;
- ORGANIZATIONNAME = GMoledina.ca;
- };
- buildConfigurationList = 16924B01144156FD00E6E556 /* Build configuration list for PBXProject "GMGridView" */;
- compatibilityVersion = "Xcode 3.2";
- developmentRegion = English;
- hasScannedForEncodings = 0;
- knownRegions = (
- en,
- );
- mainGroup = 16924AFC144156FD00E6E556;
- productRefGroup = 16924B08144156FE00E6E556 /* Products */;
- projectDirPath = "";
- projectRoot = "";
- targets = (
- 16924B06144156FE00E6E556 /* GMGridView */,
- );
- };
-/* End PBXProject section */
-
-/* Begin PBXResourcesBuildPhase section */
- 16924B05144156FE00E6E556 /* Resources */ = {
- isa = PBXResourcesBuildPhase;
- buildActionMask = 2147483647;
- files = (
- 16026C131454631600093AFF /* LICENSE in Resources */,
- 16026C141454631600093AFF /* README in Resources */,
- 16955523146FA81800DECCA6 /* close_x.png in Resources */,
- );
- runOnlyForDeploymentPostprocessing = 0;
- };
-/* End PBXResourcesBuildPhase section */
-
-/* Begin PBXSourcesBuildPhase section */
- 16924B03144156FE00E6E556 /* Sources */ = {
- isa = PBXSourcesBuildPhase;
- buildActionMask = 2147483647;
- files = (
- 1691D7A41442CFC300F472BF /* main.m in Sources */,
- 1691D7AA1442D01F00F472BF /* AppDelegate.m in Sources */,
- 1691D7AB1442D01F00F472BF /* Demo1ViewController.m in Sources */,
- 1691D7AE1442D02C00F472BF /* GMGridView.m in Sources */,
- 16A0D030145342F8004D7BBC /* GMGridViewCell.m in Sources */,
- 16026C0E1454628800093AFF /* UIView+GMGridViewAdditions.m in Sources */,
- 16DF1A6E145E3456006AA43C /* GMGridViewLayoutStrategies.m in Sources */,
- 16DF1A71145E3461006AA43C /* UIGestureRecognizer+GMGridViewAdditions.m in Sources */,
- 169AE3781460E1B300C0CBCD /* OptionsViewController.m in Sources */,
- 16583C24146CC2290006F11B /* Demo2ViewController.m in Sources */,
- );
- runOnlyForDeploymentPostprocessing = 0;
- };
-/* End PBXSourcesBuildPhase section */
-
-/* Begin XCBuildConfiguration section */
- 16924B26144156FE00E6E556 /* Debug */ = {
- isa = XCBuildConfiguration;
- buildSettings = {
- ALWAYS_SEARCH_USER_PATHS = NO;
- ARCHS = "$(ARCHS_STANDARD_32_BIT)";
- CLANG_ENABLE_OBJC_ARC = YES;
- "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
- 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_VERSION = com.apple.compilers.llvm.clang.1_0;
- GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES;
- GCC_WARN_ABOUT_RETURN_TYPE = YES;
- GCC_WARN_UNUSED_VARIABLE = YES;
- IPHONEOS_DEPLOYMENT_TARGET = 5.0;
- SDKROOT = iphoneos;
- TARGETED_DEVICE_FAMILY = "1,2";
- };
- name = Debug;
- };
- 16924B27144156FE00E6E556 /* Release */ = {
- isa = XCBuildConfiguration;
- buildSettings = {
- ALWAYS_SEARCH_USER_PATHS = NO;
- ARCHS = "$(ARCHS_STANDARD_32_BIT)";
- CLANG_ENABLE_OBJC_ARC = YES;
- "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
- COPY_PHASE_STRIP = YES;
- GCC_C_LANGUAGE_STANDARD = gnu99;
- GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
- GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES;
- GCC_WARN_ABOUT_RETURN_TYPE = YES;
- GCC_WARN_UNUSED_VARIABLE = YES;
- IPHONEOS_DEPLOYMENT_TARGET = 5.0;
- OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1";
- SDKROOT = iphoneos;
- TARGETED_DEVICE_FAMILY = "1,2";
- VALIDATE_PRODUCT = YES;
- };
- name = Release;
- };
- 16924B29144156FE00E6E556 /* Debug */ = {
- isa = XCBuildConfiguration;
- buildSettings = {
- GCC_PRECOMPILE_PREFIX_HEADER = YES;
- GCC_PREFIX_HEADER = "GMGridView/GMGridView-Prefix.pch";
- INFOPLIST_FILE = "GMGridView/GMGridView-Info.plist";
- PRODUCT_NAME = GMGridView;
- WRAPPER_EXTENSION = app;
- };
- name = Debug;
- };
- 16924B2A144156FE00E6E556 /* Release */ = {
- isa = XCBuildConfiguration;
- buildSettings = {
- GCC_PRECOMPILE_PREFIX_HEADER = YES;
- GCC_PREFIX_HEADER = "GMGridView/GMGridView-Prefix.pch";
- INFOPLIST_FILE = "GMGridView/GMGridView-Info.plist";
- PRODUCT_NAME = GMGridView;
- WRAPPER_EXTENSION = app;
- };
- name = Release;
- };
-/* End XCBuildConfiguration section */
-
-/* Begin XCConfigurationList section */
- 16924B01144156FD00E6E556 /* Build configuration list for PBXProject "GMGridView" */ = {
- isa = XCConfigurationList;
- buildConfigurations = (
- 16924B26144156FE00E6E556 /* Debug */,
- 16924B27144156FE00E6E556 /* Release */,
- );
- defaultConfigurationIsVisible = 0;
- defaultConfigurationName = Release;
- };
- 16924B28144156FE00E6E556 /* Build configuration list for PBXNativeTarget "GMGridView" */ = {
- isa = XCConfigurationList;
- buildConfigurations = (
- 16924B29144156FE00E6E556 /* Debug */,
- 16924B2A144156FE00E6E556 /* Release */,
- );
- defaultConfigurationIsVisible = 0;
- defaultConfigurationName = Release;
- };
-/* End XCConfigurationList section */
- };
- rootObject = 16924AFE144156FD00E6E556 /* Project object */;
-}
View
1 GMGridView/API/GMGridView-Constants.h → GMGridView/GMGridView-Constants.h
@@ -41,6 +41,7 @@
#define __gm_weak __weak
#define gm_nil(x)
+
#else
#define gm_weak unsafe_unretained
View
66 GMGridView/API/GMGridView.h → GMGridView/GMGridView.h
@@ -42,57 +42,68 @@ typedef enum
GMGridViewStyleSwap
} GMGridViewStyle;
+typedef enum
+{
+ GMGridViewScrollPositionNone,
+ GMGridViewScrollPositionTop,
+ GMGridViewScrollPositionMiddle,
+ GMGridViewScrollPositionBottom
+} GMGridViewScrollPosition;
+
+typedef enum
+{
+ GMGridViewItemAnimationNone = 0,
+ GMGridViewItemAnimationFade,
+ GMGridViewItemAnimationScroll = 1<<7 // scroll to the item before showing the animation
+} GMGridViewItemAnimation;
//////////////////////////////////////////////////////////////
#pragma mark Interface GMGridView
//////////////////////////////////////////////////////////////
-@interface GMGridView : UIView
-{
-
-}
+@interface GMGridView : UIScrollView
// Delegates
-@property (nonatomic, gm_weak) NSObject<GMGridViewDataSource> *dataSource; // Required
-@property (nonatomic, gm_weak) NSObject<GMGridViewActionDelegate> *actionDelegate; // Optional - to get taps callback
-@property (nonatomic, gm_weak) NSObject<GMGridViewSortingDelegate> *sortingDelegate; // Optional - to enable sorting
-@property (nonatomic, gm_weak) NSObject<GMGridViewTransformationDelegate> *transformDelegate; // Optional - to enable fullsize mode
+@property (nonatomic, gm_weak) IBOutlet NSObject<GMGridViewDataSource> *dataSource; // Required
+@property (nonatomic, gm_weak) IBOutlet NSObject<GMGridViewActionDelegate> *actionDelegate; // Optional - to get taps callback & deleting item
+@property (nonatomic, gm_weak) IBOutlet NSObject<GMGridViewSortingDelegate> *sortingDelegate; // Optional - to enable sorting
+@property (nonatomic, gm_weak) IBOutlet NSObject<GMGridViewTransformationDelegate> *transformDelegate; // Optional - to enable fullsize mode
// Layout Strategy
-@property (nonatomic, strong) id<GMGridViewLayoutStrategy> layoutStrategy; // Default is GMGridViewLayoutVerticalStrategy
+@property (nonatomic, strong) IBOutlet id<GMGridViewLayoutStrategy> layoutStrategy; // Default is GMGridViewLayoutVerticalStrategy
// Editing Mode
@property (nonatomic, getter=isEditing) BOOL editing; // Default is NO - When set to YES, all gestures are disabled and delete buttons shows up on cells
+- (void)setEditing:(BOOL)editing animated:(BOOL)animated;
// Customizing Options
-@property (nonatomic, gm_weak) UIView *mainSuperView; // Default is self
+@property (nonatomic, gm_weak) IBOutlet UIView *mainSuperView; // Default is self
@property (nonatomic) GMGridViewStyle style; // Default is GMGridViewStyleSwap
@property (nonatomic) NSInteger itemSpacing; // Default is 10
@property (nonatomic) BOOL centerGrid; // Default is YES
@property (nonatomic) UIEdgeInsets minEdgeInsets; // Default is (5, 5, 5, 5)
@property (nonatomic) CFTimeInterval minimumPressDuration; // Default is 0.2; if set to 0, the scrollView will not be scrollable
@property (nonatomic) BOOL showFullSizeViewWithAlphaWhenTransforming; // Default is YES - not working right now
-@property (nonatomic) BOOL showsVerticalScrollIndicator; // Default is YES
-@property (nonatomic) BOOL showsHorizontalScrollIndicator; // Default is YES
-
-@property (nonatomic, readonly) UIScrollView *scrollView; // Messing with the scrollView can lead to unexpected behavior. Avoid changing any properties
- // or changing its delegate. You have been warned.
-
+@property (nonatomic, readonly) UIScrollView *scrollView __attribute__((deprecated)); // The grid now inherits directly from UIScrollView
// Reusable cells
- (GMGridViewCell *)dequeueReusableCell; // Should be called in GMGridView:cellForItemAtIndex: to reuse a cell
+- (GMGridViewCell *)dequeueReusableCellWithIdentifier:(NSString *)identifier;
// Cells
- (GMGridViewCell *)cellForItemAtIndex:(NSInteger)position; // Might return nil if cell not loaded for the specific index
// Actions
- (void)reloadData;
-- (void)insertObjectAtIndex:(NSInteger)index;
-- (void)removeObjectAtIndex:(NSInteger)index;
-- (void)reloadObjectAtIndex:(NSInteger)index;
-- (void)swapObjectAtIndex:(NSInteger)index1 withObjectAtIndex:(NSInteger)index2;
-- (void)scrollToObjectAtIndex:(NSInteger)index animated:(BOOL)animated;
+- (void)insertObjectAtIndex:(NSInteger)index withAnimation:(GMGridViewItemAnimation)animation;
+- (void)removeObjectAtIndex:(NSInteger)index withAnimation:(GMGridViewItemAnimation)animation;
+- (void)reloadObjectAtIndex:(NSInteger)index withAnimation:(GMGridViewItemAnimation)animation;
+- (void)swapObjectAtIndex:(NSInteger)index1 withObjectAtIndex:(NSInteger)index2 withAnimation:(GMGridViewItemAnimation)animation;
+- (void)scrollToObjectAtIndex:(NSInteger)index atScrollPosition:(GMGridViewScrollPosition)scrollPosition animated:(BOOL)animated;
+
+// Force the grid to update properties in an (probably) animated way.
+- (void)layoutSubviewsWithAnimation:(GMGridViewItemAnimation)animation;
@end
@@ -106,12 +117,12 @@ typedef enum
@required
// Populating subview items
- (NSInteger)numberOfItemsInGMGridView:(GMGridView *)gridView;
-- (CGSize)sizeForItemsInGMGridView:(GMGridView *)gridView;
+- (CGSize)GMGridView:(GMGridView *)gridView sizeForItemsInInterfaceOrientation:(UIInterfaceOrientation)orientation;
- (GMGridViewCell *)GMGridView:(GMGridView *)gridView cellForItemAtIndex:(NSInteger)index;
@optional
-// Required to enable editing mode
-- (void)GMGridView:(GMGridView *)gridView deleteItemAtIndex:(NSInteger)index;
+// Allow a cell to be deletable. If not implemented, YES is assumed.
+- (BOOL)GMGridView:(GMGridView *)gridView canDeleteItemAtIndex:(NSInteger)index;
@end
@@ -125,6 +136,11 @@ typedef enum
@required
- (void)GMGridView:(GMGridView *)gridView didTapOnItemAtIndex:(NSInteger)position;
+@optional
+// Called when the delete-button has been pressed. Required to enable editing mode.
+// This method wont delete the cell automatically. Call the delete method of the gridView when appropriate.
+- (void)GMGridView:(GMGridView *)gridView processDeleteActionForItemAtIndex:(NSInteger)index;
+
@end
@@ -156,7 +172,7 @@ typedef enum
@required
// Fullsize
-- (CGSize)GMGridView:(GMGridView *)gridView sizeInFullSizeForCell:(GMGridViewCell *)cell atIndex:(NSInteger)index;
+- (CGSize)GMGridView:(GMGridView *)gridView sizeInFullSizeForCell:(GMGridViewCell *)cell atIndex:(NSInteger)index inInterfaceOrientation:(UIInterfaceOrientation)orientation;
- (UIView *)GMGridView:(GMGridView *)gridView fullSizeViewForCell:(GMGridViewCell *)cell atIndex:(NSInteger)index;
// Transformation (pinch, drag, rotate) of the item
View
800 GMGridView/API/GMGridView.m → GMGridView/GMGridView.m
@@ -32,7 +32,7 @@
#import "GMGridViewLayoutStrategies.h"
#import "UIGestureRecognizer+GMGridViewAdditions.h"
-static const NSUInteger kTagOffset = 50;
+static const NSInteger kTagOffset = 50;
static const CGFloat kDefaultAnimationDuration = 0.3;
static const UIViewAnimationOptions kDefaultAnimationOptions = UIViewAnimationOptionBeginFromCurrentState | UIViewAnimationOptionAllowUserInteraction;
@@ -43,9 +43,6 @@
@interface GMGridView () <UIGestureRecognizerDelegate, UIScrollViewDelegate>
{
- // Views
- UIScrollView *_scrollView;
-
// Sorting Gestures
UIPanGestureRecognizer *_sortingPanGesture;
UILongPressGestureRecognizer *_sortingLongPressGesture;
@@ -74,6 +71,9 @@ @interface GMGridView () <UIGestureRecognizerDelegate, UIScrollViewDelegate>
CGFloat _lastRotation;
CGFloat _lastScale;
BOOL _inFullSizeMode;
+ BOOL _inTransformingState;
+
+ // Rotation
BOOL _rotationActive;
}
@@ -82,6 +82,7 @@ @interface GMGridView () <UIGestureRecognizerDelegate, UIScrollViewDelegate>
@property (atomic) NSInteger firstPositionLoaded;
@property (atomic) NSInteger lastPositionLoaded;
+- (void)commonInit;
// Gestures
- (void)sortingPanGestureUpdated:(UIPanGestureRecognizer *)panGesture;
@@ -103,7 +104,7 @@ - (void)transformingGestureDidFinish;
- (BOOL)isInTransformingState;
// Helpers & more
-- (void)recomputeSize;
+- (void)recomputeSizeAnimated:(BOOL)animated;
- (void)relayoutItemsAnimated:(BOOL)animated;
- (NSArray *)itemSubviews;
- (GMGridViewCell *)cellForItemAtIndex:(NSInteger)position;
@@ -142,7 +143,6 @@ @implementation GMGridView
@synthesize minEdgeInsets = _minEdgeInsets;
@synthesize showFullSizeViewWithAlphaWhenTransforming;
@synthesize editing = _editing;
-@synthesize scrollView = _scrollView;
@synthesize itemsSubviewsCacheIsValid = _itemsSubviewsCacheIsValid;
@synthesize itemSubviewsCache;
@@ -163,94 +163,103 @@ - (id)initWithFrame:(CGRect)frame
{
if ((self = [super initWithFrame:frame]))
{
- _scrollView = [[UIScrollView alloc] initWithFrame:[self bounds]];
- _scrollView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
- _scrollView.backgroundColor = [UIColor clearColor];
- _scrollView.delegate = self;
- [self addSubview:_scrollView];
-
- _tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapGestureUpdated:)];
- _tapGesture.delegate = self;
- _tapGesture.numberOfTapsRequired = 1;
- _tapGesture.numberOfTouchesRequired = 1;
- [_scrollView addGestureRecognizer:_tapGesture];
-
- /////////////////////////////
- // Transformation gestures :
- _pinchGesture = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(pinchGestureUpdated:)];
- _pinchGesture.delegate = self;
- [self addGestureRecognizer:_pinchGesture];
-
- _rotationGesture = [[UIRotationGestureRecognizer alloc] initWithTarget:self action:@selector(rotationGestureUpdated:)];
- _rotationGesture.delegate = self;
- [self addGestureRecognizer:_rotationGesture];
-
- _panGesture = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(panGestureUpdated:)];
- _panGesture.delegate = self;
- [_panGesture setMaximumNumberOfTouches:2];
- [_panGesture setMinimumNumberOfTouches:2];
- [self addGestureRecognizer:_panGesture];
-
- //////////////////////
- // Sorting gestures :
-
- _sortingPanGesture = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(sortingPanGestureUpdated:)];
- _sortingPanGesture.delegate = self;
- [_scrollView addGestureRecognizer:_sortingPanGesture];
-
- _sortingLongPressGesture = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(sortingLongPressGestureUpdated:)];
- _sortingLongPressGesture.numberOfTouchesRequired = 1;
- _sortingLongPressGesture.delegate = self;
- [_scrollView addGestureRecognizer:_sortingLongPressGesture];
-
- ////////////////////////
- // Gesture dependencies
- UIPanGestureRecognizer *panGestureRecognizer = nil;
- if ([_scrollView respondsToSelector:@selector(panGestureRecognizer)]) // iOS5 only
- {
- panGestureRecognizer = _scrollView.panGestureRecognizer;
- }
- else
- {
- for (UIGestureRecognizer *gestureRecognizer in _scrollView.gestureRecognizers)
- {
- if ([gestureRecognizer isKindOfClass:NSClassFromString(@"UIScrollViewPanGestureRecognizer")])
- {
- panGestureRecognizer = (UIPanGestureRecognizer *) gestureRecognizer;
- }
- }
- }
- [panGestureRecognizer setMaximumNumberOfTouches:1];
- [panGestureRecognizer requireGestureRecognizerToFail:_sortingPanGesture];
+ [self commonInit];
+ }
+ return self;
+}
- self.layoutStrategy = [GMGridViewLayoutStrategyFactory strategyFromType:GMGridViewLayoutVertical];
-
- self.mainSuperView = self;
- self.editing = NO;
- self.itemSpacing = 10;
- self.style = GMGridViewStyleSwap;
- self.minimumPressDuration = 0.2;
- self.showFullSizeViewWithAlphaWhenTransforming = YES;
- self.minEdgeInsets = UIEdgeInsetsMake(5, 5, 5, 5);
- self.clipsToBounds = NO;
-
- _sortFuturePosition = GMGV_INVALID_POSITION;
- _itemSize = CGSizeZero;
-
- _lastScale = 1.0;
- _lastRotation = 0.0;
-
- _minPossibleContentOffset = CGPointMake(0, 0);
- _maxPossibleContentOffset = CGPointMake(0, 0);
-
- _reusableCells = [[NSMutableSet alloc] init];
-
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(receivedMemoryWarningNotification:) name:UIApplicationDidReceiveMemoryWarningNotification object:nil];
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(willRotate:) name:UIApplicationWillChangeStatusBarOrientationNotification object:nil];
+- (id)initWithCoder:(NSCoder *)aDecoder
+{
+ if ((self = [super initWithCoder:aDecoder]))
+ {
+ [self commonInit];
}
+
return self;
}
+- (void)commonInit
+{
+ _tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapGestureUpdated:)];
+ _tapGesture.delegate = self;
+ _tapGesture.numberOfTapsRequired = 1;
+ _tapGesture.numberOfTouchesRequired = 1;
+ [self addGestureRecognizer:_tapGesture];
+
+ /////////////////////////////
+ // Transformation gestures :
+ _pinchGesture = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(pinchGestureUpdated:)];
+ _pinchGesture.delegate = self;
+ [self addGestureRecognizer:_pinchGesture];
+
+ _rotationGesture = [[UIRotationGestureRecognizer alloc] initWithTarget:self action:@selector(rotationGestureUpdated:)];
+ _rotationGesture.delegate = self;
+ [self addGestureRecognizer:_rotationGesture];
+
+ _panGesture = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(panGestureUpdated:)];
+ _panGesture.delegate = self;
+ [_panGesture setMaximumNumberOfTouches:2];
+ [_panGesture setMinimumNumberOfTouches:2];
+ [self addGestureRecognizer:_panGesture];
+
+ //////////////////////
+ // Sorting gestures :
+
+ _sortingPanGesture = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(sortingPanGestureUpdated:)];
+ _sortingPanGesture.delegate = self;
+ [self addGestureRecognizer:_sortingPanGesture];
+
+ _sortingLongPressGesture = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(sortingLongPressGestureUpdated:)];
+ _sortingLongPressGesture.numberOfTouchesRequired = 1;
+ _sortingLongPressGesture.delegate = self;
+ [self addGestureRecognizer:_sortingLongPressGesture];
+
+ ////////////////////////
+ // Gesture dependencies
+ UIPanGestureRecognizer *panGestureRecognizer = nil;
+ if ([self respondsToSelector:@selector(panGestureRecognizer)]) // iOS5 only
+ {
+ panGestureRecognizer = self.panGestureRecognizer;
+ }
+ else
+ {
+ for (UIGestureRecognizer *gestureRecognizer in self.gestureRecognizers)
+ {
+ if ([gestureRecognizer isKindOfClass:NSClassFromString(@"UIScrollViewPanGestureRecognizer")])
+ {
+ panGestureRecognizer = (UIPanGestureRecognizer *) gestureRecognizer;
+ }
+ }
+ }
+ [panGestureRecognizer setMaximumNumberOfTouches:1];
+ [panGestureRecognizer requireGestureRecognizerToFail:_sortingPanGesture];
+
+ self.layoutStrategy = [GMGridViewLayoutStrategyFactory strategyFromType:GMGridViewLayoutVertical];
+
+ self.mainSuperView = self;
+ self.editing = NO;
+ self.itemSpacing = 10;
+ self.style = GMGridViewStyleSwap;
+ self.minimumPressDuration = 0.2;
+ self.showFullSizeViewWithAlphaWhenTransforming = YES;
+ self.minEdgeInsets = UIEdgeInsetsMake(5, 5, 5, 5);
+ self.clipsToBounds = NO;
+
+ _sortFuturePosition = GMGV_INVALID_POSITION;
+ _itemSize = CGSizeZero;
+ _centerGrid = YES;
+
+ _lastScale = 1.0;
+ _lastRotation = 0.0;
+
+ _minPossibleContentOffset = CGPointMake(0, 0);
+ _maxPossibleContentOffset = CGPointMake(0, 0);
+
+ _reusableCells = [[NSMutableSet alloc] init];
+
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(receivedMemoryWarningNotification:) name:UIApplicationDidReceiveMemoryWarningNotification object:nil];
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(willRotate:) name:UIApplicationWillChangeStatusBarOrientationNotification object:nil];
+}
- (void)dealloc
{
@@ -262,41 +271,101 @@ - (void)dealloc
#pragma mark Layout
//////////////////////////////////////////////////////////////
+- (void)applyWithoutAnimation:(void (^)(void))animations
+{
+ if (animations)
+ {
+ [CATransaction begin];
+ [CATransaction setValue:(id)kCFBooleanTrue forKey:kCATransactionDisableActions];
+ animations();
+ [CATransaction commit];
+ }
+}
+
+- (void)layoutSubviewsWithAnimation:(GMGridViewItemAnimation)animation
+{
+ [self recomputeSizeAnimated:!(animation & GMGridViewItemAnimationNone)];
+ [self relayoutItemsAnimated:animation & GMGridViewItemAnimationFade]; // only supported animation for now
+ [self loadRequiredItems];
+}
+
- (void)layoutSubviews
{
[super layoutSubviews];
- void (^layoutBlock)(void) = ^{
- [self recomputeSize];
- [self relayoutItemsAnimated:NO];
- [self loadRequiredItems];
- };
-
if (_rotationActive)
{
+ _rotationActive = NO;
+
+ // Updating all the items size
+
+ CGSize itemSize = [self.dataSource GMGridView:self sizeForItemsInInterfaceOrientation:[[UIApplication sharedApplication] statusBarOrientation]];
+
+ if (!CGSizeEqualToSize(_itemSize, itemSize))
+ {
+ _itemSize = itemSize;
+
+ [[self itemSubviews] enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
+
+ if (obj != _transformingItem)
+ {
+ GMGridViewCell *cell = (GMGridViewCell *)obj;
+ cell.bounds = CGRectMake(0, 0, _itemSize.width, _itemSize.height);
+ cell.contentView.frame = cell.bounds;
+ }
+ }];
+ }
+
+ // Updating the fullview size
+
+ if (_transformingItem && _inFullSizeMode)
+ {
+ NSInteger position = _transformingItem.tag - kTagOffset;
+ CGSize fullSize = [self.transformDelegate GMGridView:self sizeInFullSizeForCell:_transformingItem atIndex:position inInterfaceOrientation:[[UIApplication sharedApplication] statusBarOrientation]];
+
+ if (!CGSizeEqualToSize(fullSize, _transformingItem.fullSize))
+ {
+ CGPoint center = _transformingItem.fullSizeView.center;
+ _transformingItem.fullSize = fullSize;
+ _transformingItem.fullSizeView.center = center;
+ }
+ }
+
+ // Adding alpha animation to make the relayouting more smooth
+
CATransition *transition = [CATransition animation];
transition.duration = 0.25f;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionFade;
- [_scrollView.layer addAnimation:transition forKey:@"rotationAnimation"];
- _rotationActive = NO;
+ [self.layer addAnimation:transition forKey:@"rotationAnimation"];
- [UIView animateWithDuration:0
- delay:0
- options:UIViewAnimationOptionOverrideInheritedDuration
- animations:^{
- layoutBlock();
- }
- completion:nil
- ];
+ [self applyWithoutAnimation:^{
+ [self layoutSubviewsWithAnimation:GMGridViewItemAnimationNone];
+ }];
}
else
{
- layoutBlock();
+ [self layoutSubviewsWithAnimation:GMGridViewItemAnimationNone];
}
}
//////////////////////////////////////////////////////////////
+#pragma mark Orientation and memory management
+//////////////////////////////////////////////////////////////
+
+- (void)receivedMemoryWarningNotification:(NSNotification *)notification
+{
+ [self cleanupUnseenItems];
+ [_reusableCells removeAllObjects];
+}
+
+- (void)willRotate:(NSNotification *)notification
+{
+ _rotationActive = YES;
+}
+
+
+//////////////////////////////////////////////////////////////
#pragma mark Setters / getters
//////////////////////////////////////////////////////////////
@@ -315,7 +384,7 @@ - (void)setLayoutStrategy:(id<GMGridViewLayoutStrategy>)layoutStrategy
{
_layoutStrategy = layoutStrategy;
- _scrollView.pagingEnabled = [[self.layoutStrategy class] requiresEnablingPaging];
+ self.pagingEnabled = [[self.layoutStrategy class] requiresEnablingPaging];
[self setNeedsLayout];
}
@@ -349,49 +418,46 @@ - (CFTimeInterval)minimumPressDuration
- (void)setEditing:(BOOL)editing
{
- if ([self.dataSource respondsToSelector:@selector(GMGridView:deleteItemAtIndex:)]
+ [self setEditing:editing animated:NO];
+}
+
+- (void)setEditing:(BOOL)editing animated:(BOOL)animated
+{
+ if ([self.actionDelegate respondsToSelector:@selector(GMGridView:processDeleteActionForItemAtIndex:)]
&&![self isInTransformingState]
&& ((self.isEditing && !editing) || (!self.isEditing && editing)))
{
for (GMGridViewCell *cell in [self itemSubviews])
{
- [cell setEditing:editing];
+ NSInteger index = [self positionForItemSubview:cell];
+ if (index != GMGV_INVALID_POSITION)
+ {
+ BOOL allowEdit = editing && [self.dataSource GMGridView:self canDeleteItemAtIndex:index];
+ [cell setEditing:allowEdit animated:animated];
+ }
}
_editing = editing;
}
}
-- (void)setShowsVerticalScrollIndicator:(BOOL)showsVerticalScroll
-{
- _scrollView.showsVerticalScrollIndicator = showsVerticalScroll;
-}
-
-- (BOOL)showsVerticalScrollIndicator
-{
- return _scrollView.showsVerticalScrollIndicator;
-}
-
-- (void)setShowsHorizontalScrollIndicator:(BOOL)showsHorizontalScrollIndicator
-{
- _scrollView.showsHorizontalScrollIndicator = showsHorizontalScrollIndicator;
-}
-
-- (BOOL)showsHorizontalScrollIndicator
-{
- return _scrollView.showsHorizontalScrollIndicator;
-}
-
-
//////////////////////////////////////////////////////////////
-#pragma mark UIScrollView delegate
+#pragma mark UIScrollView delegate replacement
//////////////////////////////////////////////////////////////
-- (void)scrollViewDidScroll:(UIScrollView *)scrollView
+- (void)contentOffset:(CGPoint)contentOffset
{
- [self loadRequiredItems];
+ BOOL valueChanged = !CGPointEqualToPoint(contentOffset, self.contentOffset);
+
+ [super setContentOffset:contentOffset];
+
+ if (valueChanged)
+ {
+ [self loadRequiredItems];
+ }
}
+
//////////////////////////////////////////////////////////////
#pragma mark GestureRecognizer delegate
//////////////////////////////////////////////////////////////
@@ -404,11 +470,11 @@ - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecogni
- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer
{
BOOL valid = YES;
- BOOL isScrolling = _scrollView.isDragging || _scrollView.isDecelerating;
+ BOOL isScrolling = self.isDragging || self.isDecelerating;
if (gestureRecognizer == _tapGesture)
{
- CGPoint locationTouch = [_tapGesture locationInView:_scrollView];
+ CGPoint locationTouch = [_tapGesture locationInView:self];
valid = !isScrolling && !self.isEditing && [self.layoutStrategy itemPositionFromLocation:locationTouch] != GMGV_INVALID_POSITION;
}
else if (gestureRecognizer == _sortingLongPressGesture)
@@ -423,8 +489,8 @@ - (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer
{
if (self.transformDelegate != nil && [gestureRecognizer numberOfTouches] == 2)
{
- CGPoint locationTouch1 = [gestureRecognizer locationOfTouch:0 inView:_scrollView];
- CGPoint locationTouch2 = [gestureRecognizer locationOfTouch:1 inView:_scrollView];
+ CGPoint locationTouch1 = [gestureRecognizer locationOfTouch:0 inView:self];
+ CGPoint locationTouch2 = [gestureRecognizer locationOfTouch:1 inView:self];
NSInteger positionTouch1 = [self.layoutStrategy itemPositionFromLocation:locationTouch1];
NSInteger positionTouch2 = [self.layoutStrategy itemPositionFromLocation:locationTouch2];
@@ -452,7 +518,7 @@ - (void)sortingLongPressGestureUpdated:(UILongPressGestureRecognizer *)longPress
{
if (!_sortMovingItem)
{
- CGPoint location = [longPressGesture locationInView:_scrollView];
+ CGPoint location = [longPressGesture locationInView:self];
NSInteger position = [self.layoutStrategy itemPositionFromLocation:location];
@@ -472,7 +538,7 @@ - (void)sortingLongPressGestureUpdated:(UILongPressGestureRecognizer *)longPress
if (_sortMovingItem)
{
- CGPoint location = [longPressGesture locationInView:_scrollView];
+ CGPoint location = [longPressGesture locationInView:self];
[self sortingMoveDidStopAtPoint:location];
}
@@ -503,10 +569,10 @@ - (void)sortingPanGestureUpdated:(UIPanGestureRecognizer *)panGesture
}
case UIGestureRecognizerStateChanged:
{
- CGPoint translation = [panGesture translationInView:_scrollView];
+ CGPoint translation = [panGesture translationInView:self];
CGPoint offset = translation;
- CGPoint locationInScroll = [panGesture locationInView:_scrollView];
-
+ CGPoint locationInScroll = [panGesture locationInView:self];
+
_sortMovingItem.transform = CGAffineTransformMakeTranslation(offset.x, offset.y);
[self sortingMoveDidContinueToPoint:locationInScroll];
@@ -522,10 +588,14 @@ - (void)sortingAutoScrollMovementCheck
if (_sortMovingItem && _autoScrollActive)
{
CGPoint locationInMainView = [_sortingPanGesture locationInView:self];
- CGPoint locationInScroll = [_sortingPanGesture locationInView:_scrollView];
-
+ locationInMainView = CGPointMake(locationInMainView.x - self.contentOffset.x,
+ locationInMainView.y -self.contentOffset.y
+ );
+
+
CGFloat threshhold = _itemSize.height;
- CGPoint offset = _scrollView.contentOffset;
+ CGPoint offset = self.contentOffset;
+ CGPoint locationInScroll = [_sortingPanGesture locationInView:self];
// Going down
if (locationInMainView.x + threshhold > self.bounds.size.width)
@@ -569,17 +639,17 @@ - (void)sortingAutoScrollMovementCheck
}
}
- if (offset.x != _scrollView.contentOffset.x || offset.y != _scrollView.contentOffset.y)
+ if (offset.x != self.contentOffset.x || offset.y != self.contentOffset.y)
{
[UIView animateWithDuration:kDefaultAnimationDuration
delay:0
options:kDefaultAnimationOptions
animations:^{
- _scrollView.contentOffset = offset;
+ self.contentOffset = offset;
}
completion:^(BOOL finished){
- _scrollView.contentOffset = offset;
+ self.contentOffset = offset;
if (_autoScrollActive)
{
@@ -603,10 +673,10 @@ - (void)sortingMoveDidStartAtPoint:(CGPoint)point
GMGridViewCell *item = [self cellForItemAtIndex:position];
- [_scrollView bringSubviewToFront:item];
+ [self bringSubviewToFront:item];
_sortMovingItem = item;
- CGRect frameInMainView = [_scrollView convertRect:_sortMovingItem.frame toView:self.mainSuperView];
+ CGRect frameInMainView = [self convertRect:_sortMovingItem.frame toView:self.mainSuperView];
[_sortMovingItem removeFromSuperview];
_sortMovingItem.frame = frameInMainView;
@@ -636,11 +706,11 @@ - (void)sortingMoveDidStopAtPoint:(CGPoint)point
_sortMovingItem.tag = _sortFuturePosition + kTagOffset;
- CGRect frameInScroll = [self.mainSuperView convertRect:_sortMovingItem.frame toView:_scrollView];
+ CGRect frameInScroll = [self.mainSuperView convertRect:_sortMovingItem.frame toView:self];
[_sortMovingItem removeFromSuperview];
_sortMovingItem.frame = frameInScroll;
- [_scrollView addSubview:_sortMovingItem];
+ [self addSubview:_sortMovingItem];
CGPoint newOrigin = [self.layoutStrategy originForItemAtPosition:_sortFuturePosition];
CGRect newFrame = CGRectMake(newOrigin.x, newOrigin.y, _itemSize.width, _itemSize.height);
@@ -697,7 +767,7 @@ - (void)sortingMoveDidContinueToPoint:(CGPoint)point
if ((v.tag == tag || (v.tag < tag && v.tag >= _sortFuturePosition + kTagOffset)) && v != _sortMovingItem )
{
v.tag = v.tag - 1;
- [_scrollView sendSubviewToBack:v];
+ [self sendSubviewToBack:v];
}
}
}
@@ -708,7 +778,7 @@ - (void)sortingMoveDidContinueToPoint:(CGPoint)point
if ((v.tag == tag || (v.tag > tag && v.tag <= _sortFuturePosition + kTagOffset)) && v != _sortMovingItem)
{
v.tag = v.tag + 1;
- [_scrollView sendSubviewToBack:v];
+ [self sendSubviewToBack:v];
}
}
}
@@ -724,7 +794,7 @@ - (void)sortingMoveDidContinueToPoint:(CGPoint)point
if (_sortMovingItem)
{
UIView *v = [self cellForItemAtIndex:position];
-
+
v.tag = _sortFuturePosition + kTagOffset;
CGPoint origin = [self.layoutStrategy originForItemAtPosition:_sortFuturePosition];
@@ -764,14 +834,14 @@ - (void)panGestureUpdated:(UIPanGestureRecognizer *)panGesture
[NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(transformingGestureDidFinish) object:nil];
[self performSelector:@selector(transformingGestureDidFinish) withObject:nil afterDelay:0.1];
- _scrollView.scrollEnabled = YES;
+ self.scrollEnabled = YES;
break;
}
case UIGestureRecognizerStateBegan:
{
[self transformingGestureDidBeginWithGesture:panGesture];
- _scrollView.scrollEnabled = NO;
+ self.scrollEnabled = NO;
break;
}
@@ -782,9 +852,9 @@ - (void)panGestureUpdated:(UIPanGestureRecognizer *)panGesture
[panGesture end];
}
- CGPoint translate = [panGesture translationInView:_scrollView];
+ CGPoint translate = [panGesture translationInView:self];
[_transformingItem.contentView setCenter:CGPointMake(_transformingItem.contentView.center.x + translate.x, _transformingItem.contentView.center.y + translate.y)];
- [panGesture setTranslation:CGPointZero inView:_scrollView];
+ [panGesture setTranslation:CGPointZero inView:self];
break;
}
@@ -833,7 +903,7 @@ - (void)pinchGestureUpdated:(UIPinchGestureRecognizer *)pinchGesture
_lastScale = [_pinchGesture scale];
currentScale += scale;
-
+
CGFloat alpha = 1 - (kMaxScale - currentScale);
alpha = MAX(0, alpha);
alpha = MIN(1, alpha);
@@ -890,15 +960,17 @@ - (void)rotationGestureUpdated:(UIRotationGestureRecognizer *)rotationGesture
- (void)transformingGestureDidBeginWithGesture:(UIGestureRecognizer *)gesture
{
- if (_inFullSizeMode && [gesture isKindOfClass:[UIPinchGestureRecognizer class]])
+ _inFullSizeMode = NO;
+
+ if (_inTransformingState && [gesture isKindOfClass:[UIPinchGestureRecognizer class]])
{
_pinchGesture.scale = 2.5;
}
- if (_inFullSizeMode)
+ if (_inTransformingState)
{
- _inFullSizeMode = NO;
-
+ _inTransformingState = NO;
+
CGPoint center = _transformingItem.fullSizeView.center;
[_transformingItem switchToFullSizeMode:NO];
@@ -908,11 +980,11 @@ - (void)transformingGestureDidBeginWithGesture:(UIGestureRecognizer *)gesture
}
else if (!_transformingItem)
{
- CGPoint locationTouch = [gesture locationOfTouch:0 inView:_scrollView];
+ CGPoint locationTouch = [gesture locationOfTouch:0 inView:self];
NSInteger positionTouch = [self.layoutStrategy itemPositionFromLocation:locationTouch];
_transformingItem = [self cellForItemAtIndex:positionTouch];
- CGRect frameInMainView = [_scrollView convertRect:_transformingItem.frame toView:self.mainSuperView];
+ CGRect frameInMainView = [self convertRect:_transformingItem.frame toView:self.mainSuperView];
[_transformingItem removeFromSuperview];
_transformingItem.frame = self.mainSuperView.bounds;
@@ -921,7 +993,7 @@ - (void)transformingGestureDidBeginWithGesture:(UIGestureRecognizer *)gesture
[self.mainSuperView addSubview:_transformingItem];
[self.mainSuperView bringSubviewToFront:_transformingItem];
- _transformingItem.fullSize = [self.transformDelegate GMGridView:self sizeInFullSizeForCell:_transformingItem atIndex:positionTouch];
+ _transformingItem.fullSize = [self.transformDelegate GMGridView:self sizeInFullSizeForCell:_transformingItem atIndex:positionTouch inInterfaceOrientation:[[UIApplication sharedApplication] statusBarOrientation]];
_transformingItem.fullSizeView = [self.transformDelegate GMGridView:self fullSizeViewForCell:_transformingItem atIndex:positionTouch];
if ([self.transformDelegate respondsToSelector:@selector(GMGridView:didStartTransformingCell:)])
@@ -940,22 +1012,22 @@ - (void)transformingGestureDidFinish
{
if ([self isInTransformingState])
{
- if (_lastScale > 2 && !_inFullSizeMode)
+ if (_lastScale > 2 && !_inTransformingState)
{
_lastRotation = 0;
_lastScale = 1;
[self bringSubviewToFront:_transformingItem];
-
+
CGFloat rotationValue = atan2f(_transformingItem.contentView.transform.b, _transformingItem.contentView.transform.a);
-
+
_transformingItem.contentView.transform = CGAffineTransformIdentity;
-
+
[_transformingItem switchToFullSizeMode:YES];
_transformingItem.backgroundColor = [[UIColor darkGrayColor] colorWithAlphaComponent:0.9];
_transformingItem.fullSizeView.transform = CGAffineTransformMakeRotation(rotationValue);
-
+
[UIView animateWithDuration:kDefaultAnimationDuration
delay:0
options:kDefaultAnimationOptions
@@ -965,6 +1037,7 @@ - (void)transformingGestureDidFinish
completion:nil
];
+ _inTransformingState = YES;
_inFullSizeMode = YES;
if ([self.transformDelegate respondsToSelector:@selector(GMGridView:didEnterFullSizeForCell:)])
@@ -977,7 +1050,7 @@ - (void)transformingGestureDidFinish
[_transformingItem.fullSizeView addGestureRecognizer:_rotationGesture];
[_transformingItem.fullSizeView addGestureRecognizer:_panGesture];
}
- else if (!_inFullSizeMode)
+ else if (!_inTransformingState)
{
_lastRotation = 0;
_lastScale = 1.0;
@@ -989,7 +1062,7 @@ - (void)transformingGestureDidFinish
CGPoint origin = [self.layoutStrategy originForItemAtPosition:position];
CGRect finalFrameInScroll = CGRectMake(origin.x, origin.y, _itemSize.width, _itemSize.height);
- CGRect finalFrameInSuperview = [_scrollView convertRect:finalFrameInScroll toView:self.mainSuperView];
+ CGRect finalFrameInSuperview = [self convertRect:finalFrameInScroll toView:self.mainSuperView];
[transformingView switchToFullSizeMode:NO];
transformingView.autoresizingMask = UIViewAutoresizingNone;
@@ -1003,17 +1076,18 @@ - (void)transformingGestureDidFinish
transformingView.backgroundColor = [UIColor clearColor];
}
completion:^(BOOL finished){
-
+
[transformingView removeFromSuperview];
transformingView.frame = finalFrameInScroll;
transformingView.contentView.frame = transformingView.bounds;
- [_scrollView addSubview:transformingView];
+ [self addSubview:transformingView];
transformingView.fullSizeView = nil;
+ _inFullSizeMode = NO;
if ([self.transformDelegate respondsToSelector:@selector(GMGridView:didEndTransformingCell:)])
{
- [self.transformDelegate GMGridView:self didEndTransformingCell:transformingView];
+ [self.transformDelegate GMGridView:self didEndTransformingCell:transformingView];
}
// Transfer the gestures back
@@ -1032,7 +1106,7 @@ - (void)transformingGestureDidFinish
- (void)tapGestureUpdated:(UITapGestureRecognizer *)tapGesture
{
- CGPoint locationTouch = [_tapGesture locationInView:_scrollView];
+ CGPoint locationTouch = [_tapGesture locationInView:self];
NSInteger position = [self.layoutStrategy itemPositionFromLocation:locationTouch];
if (position != GMGV_INVALID_POSITION)
@@ -1057,27 +1131,31 @@ - (GMGridViewCell *)newItemSubViewForPosition:(NSInteger)position
CGRect frame = CGRectMake(origin.x, origin.y, _itemSize.width, _itemSize.height);
// To make sure the frame is not animated
- [UIView animateWithDuration:0
- delay:0
- options:kDefaultAnimationOptions | UIViewAnimationOptionOverrideInheritedDuration
- animations:^{
- cell.frame = frame;
- cell.contentView.frame = cell.bounds;
- }
- completion:nil];
-
+ [self applyWithoutAnimation:^{
+ cell.frame = frame;
+ cell.contentView.frame = cell.bounds;
+ }];
+
cell.tag = position + kTagOffset;
- cell.editing = self.editing;
+ BOOL canEdit = self.editing && [self.dataSource GMGridView:self canDeleteItemAtIndex:position];
+ [cell setEditing:canEdit animated:NO];
__gm_weak GMGridView *weakSelf = self;
-
cell.deleteBlock = ^(GMGridViewCell *aCell)
{
NSInteger index = [weakSelf positionForItemSubview:aCell];
if (index != GMGV_INVALID_POSITION)
{
- [weakSelf.dataSource GMGridView:weakSelf deleteItemAtIndex:index];
- [weakSelf removeObjectAtIndex:index];
+ BOOL canDelete = YES;
+ if ([weakSelf.dataSource respondsToSelector:@selector(GMGridView:canDeleteItemAtIndex:)])
+ {
+ canDelete = [weakSelf.dataSource GMGridView:weakSelf canDeleteItemAtIndex:index];
+ }
+
+ if (canDelete && [weakSelf.actionDelegate respondsToSelector:@selector(GMGridView:processDeleteActionForItemAtIndex:)])
+ {
+ [weakSelf.actionDelegate GMGridView:weakSelf processDeleteActionForItemAtIndex:index];
+ }
}
};
@@ -1094,11 +1172,11 @@ - (NSArray *)itemSubviews
}
else
{
- @synchronized(_scrollView)
+ @synchronized(self)
{
NSMutableArray *itemSubViews = [[NSMutableArray alloc] initWithCapacity:_numberTotalItems];
- for (UIView * v in [_scrollView subviews])
+ for (UIView * v in [self subviews])
{
if ([v isKindOfClass:[GMGridViewCell class]])
{
@@ -1137,7 +1215,7 @@ - (NSInteger)positionForItemSubview:(GMGridViewCell *)view
return view.tag >= kTagOffset ? view.tag - kTagOffset : GMGV_INVALID_POSITION;
}
-- (void)recomputeSize
+- (void)recomputeSizeAnimated:(BOOL)animated
{
[self.layoutStrategy setupItemSize:_itemSize andItemSpacing:self.itemSpacing withMinEdgeInsets:self.minEdgeInsets andCenteredGrid:self.centerGrid];
[self.layoutStrategy rebaseWithItemCount:_numberTotalItems insideOfBounds:self.bounds];
@@ -1145,19 +1223,29 @@ - (void)recomputeSize
CGSize contentSize = [self.layoutStrategy contentSize];
_minPossibleContentOffset = CGPointMake(0, 0);
- _maxPossibleContentOffset = CGPointMake(contentSize.width - _scrollView.bounds.size.width + _scrollView.contentInset.right,
- contentSize.height - _scrollView.bounds.size.height + _scrollView.contentInset.bottom);
-
- [UIView animateWithDuration:kDefaultAnimationDuration
- delay:0
- options:kDefaultAnimationOptions
- animations:^{
- if (!CGSizeEqualToSize(_scrollView.contentSize, contentSize))
- {
- _scrollView.contentSize = contentSize;
- }
- }
- completion:nil];
+ _maxPossibleContentOffset = CGPointMake(contentSize.width - self.bounds.size.width + self.contentInset.right,
+ contentSize.height - self.bounds.size.height + self.contentInset.bottom);
+
+ BOOL shouldUpdateScrollviewContentSize = !CGSizeEqualToSize(self.contentSize, contentSize);
+
+ if (shouldUpdateScrollviewContentSize)
+ {
+ if (animated)
+ {
+ [UIView animateWithDuration:kDefaultAnimationDuration
+ delay:0
+ options:kDefaultAnimationOptions
+ animations:^{
+ self.contentSize = contentSize;
+ }
+ completion:nil];
+ }
+ else
+ {
+ self.contentSize = contentSize;
+ }
+ }
+
}
- (void)relayoutItemsAnimated:(BOOL)animated