From 1dd6e78eb481c4a3bdfeaa70d52edbb0cbb5f349 Mon Sep 17 00:00:00 2001 From: Alex Zolotarev Date: Tue, 7 Feb 2012 16:11:46 +0300 Subject: [PATCH] [ios] Closed #596 - Cancel button is not working on iPad. Replaced with Done button. --- iphone/Maps/Classes/SearchVC.mm | 31 ++++++------------------------- 1 file changed, 6 insertions(+), 25 deletions(-) diff --git a/iphone/Maps/Classes/SearchVC.mm b/iphone/Maps/Classes/SearchVC.mm index 08996410be..ef9d02d7f9 100644 --- a/iphone/Maps/Classes/SearchVC.mm +++ b/iphone/Maps/Classes/SearchVC.mm @@ -200,6 +200,10 @@ static void OnSearchResultCallback(search::Results const & res, int queryId) navBar.autoresizingMask = UIViewAutoresizingFlexibleWidth; UINavigationItem * item = [[[UINavigationItem alloc] init] autorelease]; item.leftBarButtonItem = [[[UIBarButtonItem alloc] initWithCustomView:m_radarButton] autorelease]; + UIBarButtonItem * closeButton = [[[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Done", @"Search Results - Close search button") style: UIBarButtonItemStyleDone + target:self action:@selector(onCloseButton:)] autorelease]; + item.rightBarButtonItem = closeButton; + m_searchBar = [[UISearchBar alloc] init]; m_searchBar.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; @@ -208,7 +212,6 @@ static void OnSearchResultCallback(search::Results const & res, int queryId) m_searchBar.text = g_lastSearchResults.m_searchString; m_searchBar.delegate = self; m_searchBar.placeholder = NSLocalizedString(@"Search map", @"Search box placeholder text"); - m_searchBar.showsCancelButton = YES; item.titleView = m_searchBar; [navBar pushNavigationItem:item animated:NO]; @@ -339,7 +342,7 @@ static void OnSearchResultCallback(search::Results const & res, int queryId) } } -- (void)searchBarCancelButtonClicked:(UISearchBar *)searchBar +- (void)onCloseButton:(id)sender { [self dismissModalViewControllerAnimated:YES]; } @@ -460,7 +463,7 @@ static void OnSearchResultCallback(search::Results const & res, int queryId) // Zoom to the feature case search::Result::RESULT_FEATURE: m_framework->ShowRect(res.GetFeatureRect()); - [self searchBarCancelButtonClicked:m_searchBar]; + [self onCloseButton:nil]; break; case search::Result::RESULT_SUGGESTION: @@ -546,28 +549,6 @@ static void OnSearchResultCallback(search::Results const & res, int queryId) //*********** End of Location manager callbacks ******************** //****************************************************************** -//****************************************************************** -//*********** Hack to keep Cancel button always enabled ************ -- (void)enableCancelButton:(UISearchBar *)aSearchBar -{ - for (id subview in [aSearchBar subviews]) - { - if ([subview isKindOfClass:[UIButton class]]) - { - [subview setEnabled:YES]; - break; - } - } -} - -- (void)searchBarTextDidEndEditing:(UISearchBar *)aSearchBar -{ - [aSearchBar resignFirstResponder]; - [self performSelector:@selector(enableCancelButton:) withObject:aSearchBar afterDelay:0.0]; -} -// ********** End of hack ****************************************** -// ***************************************************************** - // Dismiss virtual keyboard when touching tableview - (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView {