Hi everyone,
I’m currently working on a UITableView setup that uses UITableViewDiffableDataSource. Each cell contains two views:
A UILabel for a title
A WKWebView that loads dynamic HTML content
My Current Approach:
On initial load, I let all cells render with default height.
As each WKWebView finishes loading, I calculate its content height using JavaScript and store this height in a [String: CGFloat] dictionary keyed by a unique identifier for each WebView.
I then call tableView.performBatchUpdates to trigger a layout update and resize the cell.
When the same cell index and data are shown again, I retrieve the cached height from the dictionary and apply it as a constraint on the WKWebView before loading its content.
This mostly works, but occasionally, there are visual glitches — such as flickering during scrolling or incorrect cell heights temporarily shown before the height is re-applied.
My Questions:
Is this a recommended or sustainable way for handling WKWebView inside a UITableViewCell, especially with DiffableDataSource?
Are there any known best practices or alternatives to manage dynamic web content heights more smoothly in table cells?
Is it possible that the glitches are caused by layout timing issues or reentrancy of height calculation and rendering?
Any suggestions, refinements, or architectural recommendations would be greatly appreciated.
Thanks in advance!
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
I am using BGProcessingTaskRequest to fetch a API make my app up to date. Sometimes this background task execute with 10 minutes some times it take more than 10 mins, Some other times its never execute.
But in my case im provide just 1 minute to BGProcessingTaskRequest.earliestBeginDate variable. And i will share my implementation here,
My codes are,
Called the register function before app launching.
let taskId = "_________"
func registerBackgroundTaks() {
BGTaskScheduler.shared.register(forTaskWithIdentifier: taskId, using: nil) { task in
self.handleBackgroundProcessRequest(task: task as! BGProcessingTask)
}
print("Receiver called")
}
Called the scheduleBackgroundPrecessingTask function when application enter in background mode.
func scheduleBackgroundPrecessingTask() {
let request = BGProcessingTaskRequest(identifier: taskId)
request.requiresNetworkConnectivity = false // Need to true if your task need to network process. Defaults to false.
request.requiresExternalPower = false
request.earliestBeginDate = Date(timeIntervalSinceNow: 1 * 60) // Featch Image Count after 1 minute.
do {
try BGTaskScheduler.shared.submit(request)
print("Process notification triggered")
} catch {
print("Could not schedule background process: \(error)")
}
}
Could anyone share any concerns to my problem? or kindly clarify me why BGProcessingTaskRequest takes time randomly?