From 22e828cace07cb51f85e6f0396a01003ca31103d Mon Sep 17 00:00:00 2001 From: Yann Diorcet Date: Thu, 16 Aug 2012 15:47:06 +0200 Subject: [PATCH] Remove gesture recognizer from PhoneMainView when dealloc InCallViewController --- Classes/ContactDetailsViewController.m | 4 ---- Classes/InCallViewController.h | 1 + Classes/InCallViewController.m | 17 +++++++++++++---- Classes/LinphoneUI/UICompositeViewController.m | 17 ++++++++++++++++- 4 files changed, 30 insertions(+), 9 deletions(-) diff --git a/Classes/ContactDetailsViewController.m b/Classes/ContactDetailsViewController.m index aaa216eff..14fdb70f4 100644 --- a/Classes/ContactDetailsViewController.m +++ b/Classes/ContactDetailsViewController.m @@ -208,10 +208,6 @@ static void sync_address_book (ABAddressBookRef addressBook, CFDictionaryRef inf forState:(UIControlStateDisabled | UIControlStateSelected)]; } -- (void)viewDidUnload { - [super viewDidUnload]; -} - - (void)viewWillDisappear:(BOOL)animated { [super viewWillDisappear:animated]; if ([[UIDevice currentDevice].systemVersion doubleValue] < 5.0) { diff --git a/Classes/InCallViewController.h b/Classes/InCallViewController.h index b11f30ae3..46055e52b 100644 --- a/Classes/InCallViewController.h +++ b/Classes/InCallViewController.h @@ -40,6 +40,7 @@ UIView* testVideoView; #endif UICamSwitch* videoCameraSwitch; + UITapGestureRecognizer* singleFingerTap; UIActivityIndicatorView* videoWaitingForFirstImage; diff --git a/Classes/InCallViewController.m b/Classes/InCallViewController.m index 4004855ae..e836a18ef 100644 --- a/Classes/InCallViewController.m +++ b/Classes/InCallViewController.m @@ -53,7 +53,12 @@ const NSInteger SECURE_BUTTON_TAG=5; #pragma mark - Lifecycle Functions - (id)init { - return [super initWithNibName:@"InCallViewController" bundle:[NSBundle mainBundle]]; + self = [super initWithNibName:@"InCallViewController" bundle:[NSBundle mainBundle]]; + if(self != nil) { + self->singleFingerTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(showControls:)]; + self->videoZoomHandler = [[VideoZoomHandler alloc] init]; + } + return self; } - (void)dealloc { @@ -72,6 +77,9 @@ const NSInteger SECURE_BUTTON_TAG=5; [videoZoomHandler release]; + [[PhoneMainView instance].view removeGestureRecognizer:singleFingerTap]; + [singleFingerTap release]; + // Remove all observer [[NSNotificationCenter defaultCenter] removeObserver:self]; @@ -171,13 +179,10 @@ static UICompositeViewDescription *compositeDescription = nil; linphone_core_set_native_video_window_id([LinphoneManager getLc],(unsigned long)videoView); linphone_core_set_native_preview_window_id([LinphoneManager getLc],(unsigned long)videoPreview); - UITapGestureRecognizer* singleFingerTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(showControls:)]; [singleFingerTap setNumberOfTapsRequired:1]; [singleFingerTap setCancelsTouchesInView: FALSE]; [[PhoneMainView instance].view addGestureRecognizer:singleFingerTap]; - [singleFingerTap release]; - videoZoomHandler = [[VideoZoomHandler alloc] init]; [videoZoomHandler setup:videoGroup]; videoGroup.alpha = 0; @@ -186,6 +191,10 @@ static UICompositeViewDescription *compositeDescription = nil; removeTableBackground([callTableController view]); } +- (void)viewDidUnload { + [super viewDidUnload]; + [[PhoneMainView instance].view removeGestureRecognizer:singleFingerTap]; +} - (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration { [super willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration]; diff --git a/Classes/LinphoneUI/UICompositeViewController.m b/Classes/LinphoneUI/UICompositeViewController.m index 7de22a1e4..1c5362d37 100644 --- a/Classes/LinphoneUI/UICompositeViewController.m +++ b/Classes/LinphoneUI/UICompositeViewController.m @@ -244,6 +244,10 @@ return NO; } +- (void)didReceiveMemoryWarning { + [self clearCache]; +} + #pragma mark - Event Functions @@ -259,7 +263,18 @@ #pragma mark - - (void)clearCache { - [viewControllerCache removeAllObjects]; + for(NSString *key in [viewControllerCache allKeys]) { + UIViewController *vc = [viewControllerCache objectForKey:key]; + if(vc != self.stateBarViewController && + vc != self.tabBarViewController && + vc != self.contentViewController) { + if ([[UIDevice currentDevice].systemVersion doubleValue] >= 5.0) { + [vc viewWillUnload]; + } + [vc viewDidUnload]; + } + [viewControllerCache removeObjectForKey:key]; + } } - (UIInterfaceOrientation)currentOrientation {