From 99d57deb5d83be1d5957bfa43e1fabfee9294ebe Mon Sep 17 00:00:00 2001 From: Dmitry M Date: Fri, 25 Jul 2014 09:17:44 -0700 Subject: [PATCH] Defer updating settings until the settings dialog is closed. Fixes https://github.com/readium/SDKLauncher-iOS/issues/22 --- Classes/EPubSettings.h | 1 + Classes/EPubSettings.m | 8 ++++---- Classes/EPubSettingsController.m | 5 +++++ 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/Classes/EPubSettings.h b/Classes/EPubSettings.h index 62b4769..b44c857 100644 --- a/Classes/EPubSettings.h +++ b/Classes/EPubSettings.h @@ -52,5 +52,6 @@ typedef enum { @property (nonatomic, assign) EPubSettingsSyntheticSpread syntheticSpread; + (EPubSettings *)shared; +- (void) update; @end diff --git a/Classes/EPubSettings.m b/Classes/EPubSettings.m index 96df013..cba3b72 100644 --- a/Classes/EPubSettings.m +++ b/Classes/EPubSettings.m @@ -55,6 +55,10 @@ - (CGFloat)columnGap { } +- (void) update { + [self postNotification]; +} + - (NSDictionary *)dictionary { EPubSettingsScroll scroll = [Settings shared].scroll; EPubSettingsSyntheticSpread syntheticSpread = [Settings shared].syntheticSpread; @@ -91,7 +95,6 @@ - (EPubSettingsScroll)scroll { - (void)setColumnGap:(CGFloat)columnGap { if ([Settings shared].columnGap != columnGap) { [Settings shared].columnGap = columnGap; - [self postNotification]; } } @@ -99,7 +102,6 @@ - (void)setColumnGap:(CGFloat)columnGap { - (void)setFontScale:(CGFloat)fontScale { if ([Settings shared].fontScale != fontScale) { [Settings shared].fontScale = fontScale; - [self postNotification]; } } @@ -107,7 +109,6 @@ - (void)setFontScale:(CGFloat)fontScale { - (void)setScroll:(EPubSettingsScroll)scroll { if ([Settings shared].scroll != scroll) { [Settings shared].scroll = scroll; - [self postNotification]; } } @@ -115,7 +116,6 @@ - (void)setScroll:(EPubSettingsScroll)scroll { - (void)setSyntheticSpread:(EPubSettingsSyntheticSpread)syntheticSpread { if ([Settings shared].syntheticSpread != syntheticSpread) { [Settings shared].syntheticSpread = syntheticSpread; - [self postNotification]; } } diff --git a/Classes/EPubSettingsController.m b/Classes/EPubSettingsController.m index d5a2bb7..b4d73b1 100644 --- a/Classes/EPubSettingsController.m +++ b/Classes/EPubSettingsController.m @@ -195,15 +195,18 @@ - (void)loadView { - (void)onColumnGapDidChange:(UIStepper *)stepper { [EPubSettings shared].columnGap = stepper.value; + [self updateCells]; } - (void)onFontScaleDidChange:(UIStepper *)stepper { [EPubSettings shared].fontScale = stepper.value; + [self updateCells]; } - (void)onTapDone { + [[EPubSettings shared] update]; [self dismissViewControllerAnimated:YES completion:nil]; } @@ -241,6 +244,8 @@ - (void)onTapDone { else if (cell == m_cellSyntheticSpreadSingle) { [EPubSettings shared].syntheticSpread = EPubSettingsSyntheticSpreadSingle; } + + [self updateCells]; }