Selaa lähdekoodia

tap twice on navbar for show or hide search bar for media library

Signed-off-by: Felix Paul Kühne <fkuehne@videolan.org>
Pierre SAGASPE 11 vuotta sitten
vanhempi
commit
e815b7464e
1 muutettua tiedostoa jossa 14 lisäystä ja 2 poistoa
  1. 14 2
      Sources/VLCPlaylistViewController.m

+ 14 - 2
Sources/VLCPlaylistViewController.m

@@ -163,7 +163,10 @@ static NSString *kDisplayedFirstSteps = @"Did we display the first steps tutoria
         _searchDisplayController.searchResultsDataSource = self;
         _searchDisplayController.searchResultsDelegate = self;
         _searchBar.delegate = self;
-        self.tableView.tableHeaderView = _searchBar;
+
+        UITapGestureRecognizer *tapTwiceGesture = [[UITapGestureRecognizer alloc] initWithTarget:self  action:@selector(tapTwiceGestureAction:)];
+        [tapTwiceGesture setNumberOfTapsRequired:2];
+        [self.navigationController.navigationBar addGestureRecognizer:tapTwiceGesture];
     }
 
     _searchData = [[NSMutableArray alloc] init];
@@ -601,7 +604,7 @@ static NSString *kDisplayedFirstSteps = @"Did we display the first steps tutoria
     }
 }
 
-#pragma mark - table view gestures
+#pragma mark - Gesture Action
 - (void)swipeRightGestureAction:(UIGestureRecognizer *)recognizer
 {
     if ([[self.editButtonItem title] isEqualToString:NSLocalizedString(@"BUTTON_CANCEL",@"")])
@@ -616,6 +619,15 @@ static NSString *kDisplayedFirstSteps = @"Did we display the first steps tutoria
     }
 }
 
+- (void)tapTwiceGestureAction:(UIGestureRecognizer *)recognizer
+{
+    _searchBar.hidden = !_searchBar.hidden;
+    if (_searchBar.hidden)
+        self.tableView.tableHeaderView = nil;
+    else
+        self.tableView.tableHeaderView = _searchBar;
+}
+
 #pragma mark - Collection View
 - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
 {