[iOS] PlaceAndCompass initialisation rule changed. Fixed problem on iOS 4.3 iPod

This commit is contained in:
Kirill Zhdanovich 2013-07-01 14:04:02 +03:00 committed by Alex Zolotarev
parent 171b6cd02b
commit 348420a61a
2 changed files with 38 additions and 35 deletions

View file

@ -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

View file

@ -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