Fix table pre-scrolling to selection

iOS is broken, must wrap in a DispatchQueue.main.async
This commit is contained in:
Davide De Rosa 2019-04-05 12:46:50 +02:00
parent 8a7b0389ed
commit a4a82fbd03
6 changed files with 16 additions and 4 deletions

View File

@ -120,7 +120,7 @@ class EndpointViewController: UIViewController, TableModelHost {
tableView.reloadData()
if let ip = selectedIndexPath {
tableView.scrollToRow(at: ip, at: .middle, animated: false)
tableView.scrollToRowAsync(at: ip)
}
}

View File

@ -100,7 +100,7 @@ class OrganizerViewController: UITableViewController, TableModelHost {
tableView.reloadData()
if let ip = selectedIndexPath {
tableView.scrollToRow(at: ip, at: .middle, animated: false)
tableView.scrollToRowAsync(at: ip)
}
service.delegate = self

View File

@ -53,7 +53,7 @@ class ProviderPoolViewController: UIViewController {
title = L10n.Service.Cells.Provider.Pool.caption
tableView.reloadData()
if let ip = selectedIndexPath {
tableView.scrollToRow(at: ip, at: .middle, animated: false)
tableView.scrollToRowAsync(at: ip)
}
}
}

View File

@ -57,7 +57,7 @@ class ProviderPresetViewController: UIViewController {
title = L10n.Service.Cells.Provider.Preset.caption
tableView.reloadData()
if let ip = selectedIndexPath {
tableView.scrollToRow(at: ip, at: .middle, animated: false)
tableView.scrollToRowAsync(at: ip)
}
}

View File

@ -258,6 +258,10 @@ public class AppConstants {
"Circle Icons",
"The logo is taken from the awesome Circle Icons set by Nick Roach."
),
Notice(
"Country flags",
"https://github.com/lipis/flag-icon-css"
),
Notice(
"OpenVPN",
"© 2002-2018 OpenVPN Inc. - OpenVPN is a registered trademark of OpenVPN Inc."

View File

@ -223,3 +223,11 @@ public extension Array where Element: CustomStringConvertible {
return sorted { $0.description.lowercased() < $1.description.lowercased() }
}
}
public extension UITableView {
func scrollToRowAsync(at indexPath: IndexPath) {
DispatchQueue.main.async { [weak self] in
self?.scrollToRow(at: indexPath, at: .middle, animated: false)
}
}
}