问题
Upgraded to XCode 9.2 and now my app behaves badly on the ios simulator. It still runs ok when deployed to a physical device.
The problem is that pages are taking from 10secs to 1 minute to refresh. eg after a tableview.reloadDate(). I am certain the reloading of the data is occurring immediately, it just that the page isn't being displayed until after a long delay
Interestingly if I tap the simulator screen the response is as if I tapped the refreshed (but as yet undisplayed) page.
I don't think this is an animation issue, I have made sure that in the simulator Debug menu that 'Slow Animations' is not toggled on. Also I have 'Optimize Rendering for Windows Scale' checked.
EDIT To provide a bit more info I have provided a sample code. If someone using Xcode 9.2 could create a Single Page App and place a tableView into the View Controller and then add the code below to the swift file and run it on the 11.2 simulator and let me know how it goes I would be very grateful. Just be aware that when you tap on a cell it should redraw the table with the next level of data, for me this will take up to one minute. If you tap prior to the screen being updated then the page will be redrawn immediately (but act as though you tapped on the page which hadn't been yet been drawn).
Alternatively just peruse the code and see if you can spot something that would lead to the issue.
import UIKit
class ViewController: UIViewController, UITableViewDataSource, UITableViewDelegate {
@IBOutlet weak var tableView: UITableView!
var level = 1
let data1 = ["One - one", "One - two", "One - three"]
let data2 = ["Two - one", "Two - two", "Two - three"]
let data3 = ["Back to One"]
var data: Array<String> = Array<String>()
override func viewDidLoad() {
super.viewDidLoad()
tableView.dataSource = self
tableView.delegate = self
data = data1
}
func numberOfSections(in tableView: UITableView) -> Int {
return 1
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return data.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "cellId")!
let text = data[indexPath.row]
cell.textLabel?.text = text
return cell
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
print("Cell selected from data\(level)" )
level += 1
if level == 2 {
data = data2
} else if level == 3 {
data = data3
} else if level == 4 {
data = data1
level = 1
}
tableView.reloadData()
print("Data loaded")
}
}
NOTE: I know this code is rubbish, but it demonstrate the issues please do not critique its uselessness.
来源:https://stackoverflow.com/questions/48179107/xcode-simulator-delays-the-displaying-of-a-page