I noticed that in some cases the TimelineContainer cannot correctly calculate the distance to the nearest EventView. I was able to reproduce this error today. The project demonstrating the bug is located here. Just switch to segment 3 and you will see this:
I did a little digging in the code and noticed that this happens due to the fact that in the TimelineContainer#setTimelineOffset(offset:animated:) method changing the bottomOfScrollView to a negative value. This, in turn, is due to the fact that the contentSize.height at the time of calculation is 0. I suspect this is due to the fact that the calculation takes place before the subviews were layout.
Code I'm using with CalendarKit
In short, I have a controller for SegmentedControll that will switch tabs inside contentView. The tab bar is hidden, so it looks like the SegmentedControll screens just like the TabBarController does. I highly recommend looking at the entire bug demostrate project to better understand how everything works.
SegmentedHostViewController.swift
import UIKit
class SegmentedHostViewController: UIViewController {
@IBOutlet weak var segmentedControl: UISegmentedControl!
@IBOutlet weak var containerView: UIView!
private var contentViewContoller: UITabBarController?
override func viewDidLoad() {
super.viewDidLoad()
// Убираем линию под navbar'ом
self.navigationController?.navigationBar.shadowImage = UIImage()
}
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if (segue.identifier == "segueSegmentedHostContent") {
contentViewContoller = segue.destination as! UITabBarController
}
}
@IBAction func onSegmentChanged(_ sender: UISegmentedControl) {
contentViewContoller?.selectedIndex = sender.selectedSegmentIndex
}
}
Hi, thanks for the report. Looking at your description, it seems like it's a lifecycle issue. Could you please try to analyze the root cause and try to narrow down the prbolem?
New Issue Checklist
Issue Description
I noticed that in some cases the
TimelineContainer
cannot correctly calculate the distance to the nearestEventView
. I was able to reproduce this error today. The project demonstrating the bug is located here. Just switch to segment 3 and you will see this:I did a little digging in the code and noticed that this happens due to the fact that in the
TimelineContainer#setTimelineOffset(offset:animated:)
method changing thebottomOfScrollView
to a negative value. This, in turn, is due to the fact that thecontentSize.height
at the time of calculation is 0. I suspect this is due to the fact that the calculation takes place before the subviews were layout.Code I'm using with CalendarKit
In short, I have a controller for
SegmentedControll
that will switch tabs insidecontentView
. The tab bar is hidden, so it looks like theSegmentedControll
screens just like theTabBarController
does. I highly recommend looking at the entire bug demostrate project to better understand how everything works.SegmentedHostViewController.swift
MyDayviewController.swift