From 490a0f2c79df62a3bc2c3464800e03c552f1c56c Mon Sep 17 00:00:00 2001 From: VladiMihaylenko Date: Thu, 4 Feb 2016 18:25:56 +0300 Subject: [PATCH] [ios] Fixed edit street controller. --- .../Classes/Editor/MWMEditorSpacerCell.xib | 4 +- .../MWMStreetEditorEditTableViewCell.xib | 30 +---------- .../Street/MWMStreetEditorViewController.h | 4 +- .../Street/MWMStreetEditorViewController.mm | 22 ++++---- iphone/Maps/Mapsme.storyboard | 54 +++++-------------- 5 files changed, 29 insertions(+), 85 deletions(-) diff --git a/iphone/Maps/Classes/Editor/MWMEditorSpacerCell.xib b/iphone/Maps/Classes/Editor/MWMEditorSpacerCell.xib index 9317d240c9..85159f13d5 100644 --- a/iphone/Maps/Classes/Editor/MWMEditorSpacerCell.xib +++ b/iphone/Maps/Classes/Editor/MWMEditorSpacerCell.xib @@ -7,11 +7,11 @@ - + - + diff --git a/iphone/Maps/Classes/Editor/Street/MWMStreetEditorEditTableViewCell.xib b/iphone/Maps/Classes/Editor/Street/MWMStreetEditorEditTableViewCell.xib index 19a3162f75..785b8981c1 100644 --- a/iphone/Maps/Classes/Editor/Street/MWMStreetEditorEditTableViewCell.xib +++ b/iphone/Maps/Classes/Editor/Street/MWMStreetEditorEditTableViewCell.xib @@ -7,23 +7,13 @@ - + - + - - - - - - - - - - @@ -42,28 +32,12 @@ - - - - - - - - - - - - - - - - diff --git a/iphone/Maps/Classes/Editor/Street/MWMStreetEditorViewController.h b/iphone/Maps/Classes/Editor/Street/MWMStreetEditorViewController.h index 16860a7b8b..5133957672 100644 --- a/iphone/Maps/Classes/Editor/Street/MWMStreetEditorViewController.h +++ b/iphone/Maps/Classes/Editor/Street/MWMStreetEditorViewController.h @@ -1,4 +1,4 @@ -#import "ViewController.h" +#import "TableViewController.h" @protocol MWMStreetEditorProtocol @@ -9,7 +9,7 @@ @end -@interface MWMStreetEditorViewController : ViewController +@interface MWMStreetEditorViewController : TableViewController @property (weak, nonatomic) id delegate; diff --git a/iphone/Maps/Classes/Editor/Street/MWMStreetEditorViewController.mm b/iphone/Maps/Classes/Editor/Street/MWMStreetEditorViewController.mm index 71b27341c0..fd28a49023 100644 --- a/iphone/Maps/Classes/Editor/Street/MWMStreetEditorViewController.mm +++ b/iphone/Maps/Classes/Editor/Street/MWMStreetEditorViewController.mm @@ -5,7 +5,6 @@ namespace { NSString * const kStreetEditorCommonCell = @"MWMStreetEditorCommonTableViewCell"; - NSString * const kStreetEditorSpacerCell = @"MWMEditorSpacerCell"; NSString * const kStreetEditorEditCell = @"MWMStreetEditorEditTableViewCell"; } // namespace @@ -13,8 +12,6 @@ namespace MWMStreetEditorCommonTableViewCellProtocol, MWMStreetEditorEditCellProtocol> -@property (weak, nonatomic) IBOutlet UITableView * tableView; - @property (nonatomic) NSMutableArray * streets; @property (nonatomic) NSUInteger selectedStreet; @@ -70,8 +67,6 @@ namespace { [self.tableView registerNib:[UINib nibWithNibName:kStreetEditorCommonCell bundle:nil] forCellReuseIdentifier:kStreetEditorCommonCell]; - [self.tableView registerNib:[UINib nibWithNibName:kStreetEditorSpacerCell bundle:nil] - forCellReuseIdentifier:kStreetEditorSpacerCell]; [self.tableView registerNib:[UINib nibWithNibName:kStreetEditorEditCell bundle:nil] forCellReuseIdentifier:kStreetEditorEditCell]; } @@ -150,24 +145,25 @@ namespace NSUInteger const streetsCount = self.streets.count; if (streetsCount == 0) return [tableView dequeueReusableCellWithIdentifier:kStreetEditorEditCell]; - NSUInteger const index = indexPath.row; - if (index < streetsCount) + if (indexPath.section == 0) return [tableView dequeueReusableCellWithIdentifier:kStreetEditorCommonCell]; - else if (index == streetsCount) - return [tableView dequeueReusableCellWithIdentifier:kStreetEditorSpacerCell]; else return [tableView dequeueReusableCellWithIdentifier:kStreetEditorEditCell]; } - (NSInteger)tableView:(UITableView * _Nonnull)tableView numberOfRowsInSection:(NSInteger)section { - NSUInteger count = self.streets.count; - if (count != 0) - count++; // Spacer cell; - count++; + NSUInteger const count = self.streets.count; + if ((section == 0 && count == 0) || section != 0) + return 1; return count; } +- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView +{ + return self.streets.count > 0 ? 2 : 1; +} + #pragma mark - UITableViewDelegate - (void)tableView:(UITableView * _Nonnull)tableView willDisplayCell:(UITableViewCell * _Nonnull)cell forRowAtIndexPath:(NSIndexPath * _Nonnull)indexPath diff --git a/iphone/Maps/Mapsme.storyboard b/iphone/Maps/Mapsme.storyboard index 06112ecedf..b53fc625a7 100644 --- a/iphone/Maps/Mapsme.storyboard +++ b/iphone/Maps/Mapsme.storyboard @@ -770,7 +770,7 @@ - + @@ -2508,49 +2508,23 @@ the world. Join us! - + - - - - - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + - +