Procházet zdrojové kódy

tap twice gesture recognizer: remove target before it stops to exist

Felix Paul Kühne před 10 roky
rodič
revize
382a54cb0d

+ 9 - 3
Sources/VLCLocalPlexFolderListViewController.m

@@ -41,11 +41,17 @@
     UISearchDisplayController *_searchDisplayController;
     UIRefreshControl *_refreshControl;
     UIBarButtonItem *_menuButton;
+    UITapGestureRecognizer *_tapTwiceGestureRecognizer;
 }
 @end
 
 @implementation VLCLocalPlexFolderListViewController
 
+- (void)dealloc
+{
+    [_tapTwiceGestureRecognizer removeTarget:self action:NULL];
+}
+
 - (void)loadView
 {
     _tableView = [[UITableView alloc] initWithFrame:[UIScreen mainScreen].bounds style:UITableViewStylePlain];
@@ -107,9 +113,9 @@
     //self.tableView.tableHeaderView = _searchBar;
     //self.tableView.contentOffset = CGPointMake(0, CGRectGetHeight(_searchBar.frame)); // -> hide search bar to load
 
-    UITapGestureRecognizer *tapTwiceGesture = [[UITapGestureRecognizer alloc] initWithTarget:self  action:@selector(tapTwiceGestureAction:)];
-    [tapTwiceGesture setNumberOfTapsRequired:2];
-    [self.navigationController.navigationBar addGestureRecognizer:tapTwiceGesture];
+    _tapTwiceGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self  action:@selector(tapTwiceGestureAction:)];
+    [_tapTwiceGestureRecognizer setNumberOfTapsRequired:2];
+    [self.navigationController.navigationBar addGestureRecognizer:_tapTwiceGestureRecognizer];
 
     // Active le Pull down to refresh
     _refreshControl = [[UIRefreshControl alloc] init];

+ 9 - 3
Sources/VLCNetworkListViewController.m

@@ -21,12 +21,18 @@ NSString *VLCNetworkListCellIdentifier = @"VLCNetworkListCellIdentifier";
     NSMutableArray *_searchData;
     UISearchBar *_searchBar;
     UISearchDisplayController *_searchDisplayController;
+    UITapGestureRecognizer *_tapTwiceGestureRecognizer;
 }
 
 @end
 
 @implementation VLCNetworkListViewController
 
+- (void)dealloc
+{
+    [_tapTwiceGestureRecognizer removeTarget:self action:NULL];
+}
+
 - (void)loadView
 {
     _tableView = [[UITableView alloc] initWithFrame:[UIScreen mainScreen].bounds style:UITableViewStylePlain];
@@ -63,9 +69,9 @@ NSString *VLCNetworkListCellIdentifier = @"VLCNetworkListCellIdentifier";
     _searchBar.delegate = self;
     _searchBar.hidden = YES;
 
-    UITapGestureRecognizer *tapTwiceGesture = [[UITapGestureRecognizer alloc] initWithTarget:self  action:@selector(tapTwiceGestureAction:)];
-    [tapTwiceGesture setNumberOfTapsRequired:2];
-    [self.navigationController.navigationBar addGestureRecognizer:tapTwiceGesture];
+    _tapTwiceGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self  action:@selector(tapTwiceGestureAction:)];
+    [_tapTwiceGestureRecognizer setNumberOfTapsRequired:2];
+    [self.navigationController.navigationBar addGestureRecognizer:_tapTwiceGestureRecognizer];
 
     self.navigationItem.rightBarButtonItem = [UIBarButtonItem themedRevealMenuButtonWithTarget:self andSelector:@selector(menuButtonAction:)];
 

+ 9 - 3
Sources/VLCPlaylistViewController.m

@@ -56,6 +56,7 @@ static NSString *kUsingTableViewToShowData = @"UsingTableViewToShowData";
     LXReorderableCollectionViewFlowLayout *_reorderLayout;
     BOOL _inFolder;
     UILongPressGestureRecognizer *_longPressGestureRecognizer;
+    UITapGestureRecognizer *_tapTwiceGestureRecognizer;
 
     NSMutableArray *_searchData;
     UISearchBar *_searchBar;
@@ -75,6 +76,11 @@ static NSString *kUsingTableViewToShowData = @"UsingTableViewToShowData";
 
 @implementation VLCPlaylistViewController
 
+- (void)dealloc
+{
+    [_tapTwiceGestureRecognizer removeTarget:self action:NULL];
+}
+
 + (void)initialize
 {
     NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
@@ -200,9 +206,9 @@ static NSString *kUsingTableViewToShowData = @"UsingTableViewToShowData";
     _searchBar.delegate = self;
     _searchBar.hidden = YES;
 
-    UITapGestureRecognizer *tapTwiceGesture = [[UITapGestureRecognizer alloc] initWithTarget:self  action:@selector(tapTwiceGestureAction:)];
-    [tapTwiceGesture setNumberOfTapsRequired:2];
-    [self.navigationController.navigationBar addGestureRecognizer:tapTwiceGesture];
+    _tapTwiceGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self  action:@selector(tapTwiceGestureAction:)];
+    [_tapTwiceGestureRecognizer setNumberOfTapsRequired:2];
+    [self.navigationController.navigationBar addGestureRecognizer:_tapTwiceGestureRecognizer];
 
     _searchData = [[NSMutableArray alloc] init];
 }

+ 9 - 3
Sources/VLCSharedLibraryListViewController.m

@@ -35,11 +35,17 @@
     UISearchDisplayController *_searchDisplayController;
     UIRefreshControl *_refreshControl;
     UIBarButtonItem *_menuButton;
+    UITapGestureRecognizer *_tapTwiceGestureRecognizer;
 }
 @end
 
 @implementation VLCSharedLibraryListViewController
 
+- (void)dealloc
+{
+    [_tapTwiceGestureRecognizer removeTarget:self action:NULL];
+}
+
 - (void)loadView
 {
     _tableView = [[UITableView alloc] initWithFrame:[UIScreen mainScreen].bounds style:UITableViewStylePlain];
@@ -101,9 +107,9 @@
     _searchBar.delegate = self;
     _searchBar.hidden = YES;
 
-    UITapGestureRecognizer *tapTwiceGesture = [[UITapGestureRecognizer alloc] initWithTarget:self  action:@selector(tapTwiceGestureAction:)];
-    [tapTwiceGesture setNumberOfTapsRequired:2];
-    [self.navigationController.navigationBar addGestureRecognizer:tapTwiceGesture];
+    _tapTwiceGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self  action:@selector(tapTwiceGestureAction:)];
+    [_tapTwiceGestureRecognizer setNumberOfTapsRequired:2];
+    [self.navigationController.navigationBar addGestureRecognizer:_tapTwiceGestureRecognizer];
 
     // Active le Pull down to refresh
     _refreshControl = [[UIRefreshControl alloc] init];