Permalink
Browse files

Added gesture options to Demo app & Readme

  • Loading branch information...
1 parent 0135d17 commit 44ec4217118c8ee20615fa36457abfd64641bbc8 Ortwin Gentz committed May 3, 2012
Showing with 72 additions and 1 deletion.
  1. +1 −0 Example/Demo1ViewController.m
  2. +65 −1 Example/OptionsViewController.m
  3. +6 −0 README.md
@@ -263,6 +263,7 @@ - (GMGridViewCell *)GMGridView:(GMGridView *)gridView cellForItemAtIndex:(NSInte
label.textAlignment = UITextAlignmentCenter;
label.backgroundColor = [UIColor clearColor];
label.textColor = [UIColor blackColor];
+ label.highlightedTextColor = [UIColor whiteColor];
label.font = [UIFont boldSystemFontOfSize:20];
[cell.contentView addSubview:label];
@@ -15,6 +15,7 @@
OptionSectionGeneral = 0,
OptionSectionLayout,
OptionSectionSorting,
+ OptionSectionGestures,
OptionSectionDebug,
OptionSectionsCount
@@ -44,6 +45,14 @@
OptionSortingCount
} OptionsTypeSorting;
+// Options Gestures
+typedef enum {
+ OptionTypeGesturesEditOnTap = 0,
+ OptionTypeGesturesDisableEditOnEmptySpaceTap,
+
+ OptionTypeGesturesCount
+} OptionsTypeGestures;
+
// Options debug
typedef enum {
OptionTypeDebugGridBackground = 0,
@@ -62,6 +71,8 @@ - (void)sortStyleSegmentedControlChanged:(UISegmentedControl *)control;
- (void)layoutCenterSwitchChanged:(UISwitch *)control;
- (void)layoutSpacingSliderChanged:(UISlider *)control;
- (void)layoutInsetsSliderChanged:(UISlider *)control;
+- (void)editOnTapSwitchChanged:(UISwitch *)control;
+- (void)disableEditOnEmptySpaceTapSwitchChanged:(UISwitch *)control;
- (void)debugGridBackgroundSwitchChanged:(UISwitch *)control;
- (void)debugReloadButtonPressed:(UIButton *)control;
@@ -167,6 +178,9 @@ - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInte
case OptionSectionSorting:
title = @"Sorting";
break;
+ case OptionSectionGestures:
+ title = @"Gestures";
+ break;
case OptionSectionDebug:
title = @"Debug";
break;
@@ -190,6 +204,9 @@ - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger
case OptionSectionSorting:
count = OptionSortingCount;
break;
+ case OptionSectionGestures:
+ count = OptionTypeGesturesCount;
+ break;
case OptionSectionDebug:
count = OptionDebugCount;
break;
@@ -208,7 +225,14 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellIdentifier];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
}
-
+ else
+ {
+ for (UIView* subview in cell.contentView.subviews) {
+ if ([subview isKindOfClass:[UIPickerView class]]) {
+ [subview removeFromSuperview];
+ }
+ }
+ }
if ([indexPath section] == OptionSectionGeneral)
{
@@ -324,6 +348,36 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
}
}
}
+ else if ([indexPath section] == OptionSectionGestures)
+ {
+ switch ([indexPath row])
+ {
+ case OptionTypeGesturesEditOnTap:
+ {
+ cell.detailTextLabel.text = @"Edit on Long Tap";
+
+ UISwitch *editOnTapSwitch = [[UISwitch alloc] initWithFrame:CGRectMake(0, 0, 100, 30)];
+ [editOnTapSwitch addTarget:self action:@selector(editOnTapSwitchChanged:) forControlEvents:UIControlEventValueChanged];
+ editOnTapSwitch.on = self.gridView.enableEditOnLongPress;
+
+ cell.accessoryView = editOnTapSwitch;
+
+ break;
+ }
+ case OptionTypeGesturesDisableEditOnEmptySpaceTap:
+ {
+ cell.detailTextLabel.text = @"Disable edit on empty tap";
+
+ UISwitch *disableEditOnEmptyTapSwitch = [[UISwitch alloc] initWithFrame:CGRectMake(0, 0, 100, 30)];
+ [disableEditOnEmptyTapSwitch addTarget:self action:@selector(disableEditOnEmptySpaceTapSwitchChanged:) forControlEvents:UIControlEventValueChanged];
+ disableEditOnEmptyTapSwitch.on = self.gridView.enableEditOnLongPress;
+
+ cell.accessoryView = disableEditOnEmptyTapSwitch;
+
+ break;
+ }
+ }
+ }
else if ([indexPath section] == OptionSectionDebug)
{
switch ([indexPath row])
@@ -472,6 +526,16 @@ - (void)layoutInsetsSliderChanged:(UISlider *)control
[self.gridView layoutSubviewsWithAnimation:GMGridViewItemAnimationFade];
}
+- (void)editOnTapSwitchChanged:(UISwitch *)control
+{
+ self.gridView.enableEditOnLongPress = control.on;
+}
+
+- (void)disableEditOnEmptySpaceTapSwitchChanged:(UISwitch *)control;
+{
+ self.gridView.disableEditOnEmptySpaceTap = control.on;
+}
+
- (void)debugGridBackgroundSwitchChanged:(UISwitch *)control
{
self.gridView.backgroundColor = control.on ? [UIColor lightGrayColor] : [UIColor clearColor];
View
@@ -64,6 +64,7 @@ New feature requests are welcome. (ping [@gmoledina](http://twitter.com/gmoledin
* Paging!! 2 horizontally paged layout strategies added
* shaking animation on items when in edit mode
* Changing the scrollview delegate is allowed!
+* Cell highlighting support
* Demo app provided, with options panel
**Features - Sorting**:
@@ -73,6 +74,11 @@ New feature requests are welcome. (ping [@gmoledina](http://twitter.com/gmoledin
* Sorted view has a shake animation (can be disabled)
* Only one UIPanGestureRecognizer and one UILongTouchGestureRecognizer used to track ALL views
+**Features - Gestures**:
+
+* Perform a long-press to switch to edit (jiggle) mode
+* Tap between cells to terminate edit mode
+
**Features - Fullsize**:
* Pinch, rotate and drag views using 2 fingers

0 comments on commit 44ec421

Please sign in to comment.