Skip to content

Commit

Permalink
Fixed iOS 13 runtime warning #428
Browse files Browse the repository at this point in the history
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;
  • Loading branch information
futuretap committed Apr 8, 2020
1 parent bbdd824 commit f5198de
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
2 changes: 1 addition & 1 deletion InAppSettingsKit.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'InAppSettingsKit'
s.version = '2.14'
s.version = '2.15'
s.summary = 'This iPhone framework allows settings to be in-app in addition to being in the Settings app.'

s.description = <<-DESC
Expand Down
23 changes: 12 additions & 11 deletions InAppSettingsKit/Controllers/IASKAppSettingsViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -189,22 +189,23 @@ - (void)viewWillAppear:(BOOL)animated {

[super viewWillAppear:animated];

// if there's something selected, the value might have changed
// so reload that row
[self.tableView reloadData]; // values might have changed in the meantime

if (selectedIndexPath) {
[UIView performWithoutAnimation:^{
[self.tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:selectedIndexPath]
withRowAnimation:UITableViewRowAnimationNone];
[self.tableView selectRowAtIndexPath:selectedIndexPath animated:NO
scrollPosition:UITableViewScrollPositionNone];
}];
[self.transitionCoordinator animateAlongsideTransition:^(id<UIViewControllerTransitionCoordinatorContext> context) {
[self.tableView deselectRowAtIndexPath:selectedIndexPath animated:animated];
// Do nothing. We're only interested in the completion handler.
} completion:^(id<UIViewControllerTransitionCoordinatorContext> context) {
if ([context isCancelled]) {
[self.tableView selectRowAtIndexPath:selectedIndexPath animated:NO scrollPosition:UITableViewScrollPositionNone];
if (![context isCancelled]) {
// don't deselect if the user cancelled the interactive pop gesture
[self.tableView deselectRowAtIndexPath:selectedIndexPath animated:animated];
}
}];

// reloadData destroys the selection at the end of the runloop.
// So select again in the next runloop.
dispatch_async(dispatch_get_main_queue(), ^(void){
[self.tableView selectRowAtIndexPath:selectedIndexPath animated:NO scrollPosition:UITableViewScrollPositionNone];
});
}

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

0 comments on commit f5198de

Please sign in to comment.