From 348420a61a851c3fbb10337b61225eed3d45e9fa Mon Sep 17 00:00:00 2001 From: Kirill Zhdanovich Date: Mon, 1 Jul 2013 14:04:02 +0300 Subject: [PATCH] [iOS] PlaceAndCompass initialisation rule changed. Fixed problem on iOS 4.3 iPod --- iphone/Maps/Bookmarks/PlacePageVC.mm | 19 ++++--- .../Classes/PlacePreviewViewController.mm | 54 +++++++++---------- 2 files changed, 38 insertions(+), 35 deletions(-) diff --git a/iphone/Maps/Bookmarks/PlacePageVC.mm b/iphone/Maps/Bookmarks/PlacePageVC.mm index c08f03e732..e61420c94e 100644 --- a/iphone/Maps/Bookmarks/PlacePageVC.mm +++ b/iphone/Maps/Bookmarks/PlacePageVC.mm @@ -297,7 +297,7 @@ typedef enum {Editing, Saved} Mode; - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { if (section == 0 && m_mode == Saved) - return self.placeAndCompass; + return [self getCompassView]; if (section == 1 && [self.pinNotes length] && m_mode == Saved) { //Refactor we can do better @@ -321,14 +321,10 @@ typedef enum {Editing, Saved} Mode; - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section { if (section == 0 && m_mode == Saved) - { - if (!_placeAndCompass) - _placeAndCompass = [[PlaceAndCompasView alloc] initWithName:self.pinTitle placeSecondaryName:[NSString stringWithUTF8String:GetFramework().GetBmCategory(_pinEditedBookmark.first)->GetName().c_str()] placeGlobalPoint:_pinGlobalPosition width:self.tableView.frame.size.width]; - return self.placeAndCompass.frame.size.height; - } + return [self getCompassView].frame.size.height; if (section == 1 && [self.pinNotes length] && m_mode == Saved) return [self getDescriptionHeight] + MARGIN; - return 0; + return [self.tableView sectionHeaderHeight]; } - (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section @@ -342,7 +338,7 @@ typedef enum {Editing, Saved} Mode; { if (section == 1 && m_mode == Saved) return TWOBUTTONSHEIGHT; - return 0; + return [self.tableView sectionFooterHeight]; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath @@ -866,4 +862,11 @@ typedef enum {Editing, Saved} Mode; self.pinNotes = textView.text; } +-(PlaceAndCompasView *)getCompassView +{ + if (!self.placeAndCompass) + _placeAndCompass = [[PlaceAndCompasView alloc] initWithName:self.pinTitle placeSecondaryName:[NSString stringWithUTF8String:GetFramework().GetBmCategory(_pinEditedBookmark.first)->GetName().c_str()] placeGlobalPoint:_pinGlobalPosition width:self.tableView.frame.size.width]; + return self.placeAndCompass; +} + @end diff --git a/iphone/Maps/Classes/PlacePreviewViewController.mm b/iphone/Maps/Classes/PlacePreviewViewController.mm index 572b6b3747..ad7638f2ca 100644 --- a/iphone/Maps/Classes/PlacePreviewViewController.mm +++ b/iphone/Maps/Classes/PlacePreviewViewController.mm @@ -88,11 +88,10 @@ typedef enum {APIPOINT, POI, MYPOSITION} Type; -(void)viewDidLoad { + [super viewDidLoad]; self.navigationController.navigationBarHidden = NO; [self setTitle:NSLocalizedString(@"info", nil)]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(orientationChanged) name:UIDeviceOrientationDidChangeNotification object:nil]; - - [super viewDidLoad]; } - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView @@ -162,7 +161,7 @@ typedef enum {APIPOINT, POI, MYPOSITION} Type; - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { if (section == 0) - return self.placeAndCompass; + return [self getCompassView]; return nil; } @@ -180,35 +179,14 @@ typedef enum {APIPOINT, POI, MYPOSITION} Type; { if (section == 1) return TWOBUTTONSHEIGHT; - return 0; + return [self.tableView sectionFooterHeight]; } - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section { if (section == 0) - { - NSString * name = nil, * type = nil; - if (m_previewType == POI) - { - name = [NSString stringWithUTF8String:m_poiInfo.GetPinName().c_str()]; - char const * c = m_poiInfo.GetBestType(); - type = c ? [NSString stringWithUTF8String:c] : @""; - } - else if (m_previewType == APIPOINT) - { - name = [NSString stringWithUTF8String:m_apiPoint.m_name.c_str()]; - type = @""; - } - else - { - name = NSLocalizedString(@"my_position", nil); - type = @""; - } - if (!_placeAndCompass) - _placeAndCompass = [[PlaceAndCompasView alloc] initWithName:name placeSecondaryName:type placeGlobalPoint:m_point width:self.tableView.frame.size.width]; - return self.placeAndCompass.frame.size.height; - } - return 0; + return [self getCompassView].frame.size.height; + return [self.tableView sectionHeaderHeight]; } -(void)share @@ -361,4 +339,26 @@ typedef enum {APIPOINT, POI, MYPOSITION} Type; return YES; } +-(PlaceAndCompasView *)getCompassView +{ + if (!self.placeAndCompass) + { + NSString * name = nil; + NSString * type = @""; + if (m_previewType == POI) + { + name = [NSString stringWithUTF8String:m_poiInfo.GetPinName().c_str()]; + char const * c = m_poiInfo.GetBestType(); + type = c ? [NSString stringWithUTF8String:c] : @""; + } + else if (m_previewType == APIPOINT) + name = [NSString stringWithUTF8String:m_apiPoint.m_name.c_str()]; + else + name = NSLocalizedString(@"my_position", nil); + if (!_placeAndCompass) + _placeAndCompass = [[PlaceAndCompasView alloc] initWithName:name placeSecondaryName:type placeGlobalPoint:m_point width:self.tableView.frame.size.width]; + } + return self.placeAndCompass; +} + @end