Skip to content

Commit f5198de

Browse files
committed
Fixed iOS 13 runtime warning #428
using reloadRows in viewWillAppear triggers a UITableViewAlertForLayoutOutsideViewHierarchy warning; resolved by using reloadData instead; deselection animation is now started at the end of the transition not alongside of it;
1 parent bbdd824 commit f5198de

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

InAppSettingsKit.podspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = 'InAppSettingsKit'
3-
s.version = '2.14'
3+
s.version = '2.15'
44
s.summary = 'This iPhone framework allows settings to be in-app in addition to being in the Settings app.'
55

66
s.description = <<-DESC

InAppSettingsKit/Controllers/IASKAppSettingsViewController.m

+12-11
Original file line numberDiff line numberDiff line change
@@ -189,22 +189,23 @@ - (void)viewWillAppear:(BOOL)animated {
189189

190190
[super viewWillAppear:animated];
191191

192-
// if there's something selected, the value might have changed
193-
// so reload that row
192+
[self.tableView reloadData]; // values might have changed in the meantime
193+
194194
if (selectedIndexPath) {
195-
[UIView performWithoutAnimation:^{
196-
[self.tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:selectedIndexPath]
197-
withRowAnimation:UITableViewRowAnimationNone];
198-
[self.tableView selectRowAtIndexPath:selectedIndexPath animated:NO
199-
scrollPosition:UITableViewScrollPositionNone];
200-
}];
201195
[self.transitionCoordinator animateAlongsideTransition:^(id<UIViewControllerTransitionCoordinatorContext> context) {
202-
[self.tableView deselectRowAtIndexPath:selectedIndexPath animated:animated];
196+
// Do nothing. We're only interested in the completion handler.
203197
} completion:^(id<UIViewControllerTransitionCoordinatorContext> context) {
204-
if ([context isCancelled]) {
205-
[self.tableView selectRowAtIndexPath:selectedIndexPath animated:NO scrollPosition:UITableViewScrollPositionNone];
198+
if (![context isCancelled]) {
199+
// don't deselect if the user cancelled the interactive pop gesture
200+
[self.tableView deselectRowAtIndexPath:selectedIndexPath animated:animated];
206201
}
207202
}];
203+
204+
// reloadData destroys the selection at the end of the runloop.
205+
// So select again in the next runloop.
206+
dispatch_async(dispatch_get_main_queue(), ^(void){
207+
[self.tableView selectRowAtIndexPath:selectedIndexPath animated:NO scrollPosition:UITableViewScrollPositionNone];
208+
});
208209
}
209210

210211
if ([self.settingsStore isKindOfClass:[IASKSettingsStoreUserDefaults class]]) {

0 commit comments

Comments
 (0)