FSCalendar
FSCalendar copied to clipboard
Serious bug on iPad Pro 9.7 inch. After the app back from background, the date label will duplicate and dislocated
The following informations are requested in a bug report
- A brief bug description.
This can even be produced by the demo you supported
- Stack trace.
not yet
- Full steps to reproduce.
Here is the GIF
GIF link: http://7bv8xb.com1.z0.glb.clouddn.com/FSCalendar%20Bug.gif
- Device modal and iOS version.
e.g. iPhone 6s iOS9.1
Xcode 8 / iOS 10 / iPad Pro 9.7 inch (It works well on iPad Pro 12.9 inch)
- FSCalendar version.
e.g. FSCalenda 2.5.1
FSCalendar 2.7.9 via Cocoapods
- Does this happen in the demo project? Which one? Or a link to another demo project.
Yes, FSCalendarSwiftExample
Did you find any solution?
Try to set "UIRequiresFullScreen" in project settings. iPad supports split screen option, it seems some screen update happens after application changes state.
Yeah, possibly there is a screen update, but my app should support split screen. Any other idea?
I found that observing UIApplicationWillEnterForegroundNotification
and then calling invalidateLayout()
on the calendar view's collectionViewLayout
property seemed to fix the problem. For example:
var calendarView: FSCalendar!
override func viewDidLoad() {
super.viewDidLoad()
NotificationCenter.default.addObserver(self, selector: #selector(restoreFromBackground), name: UIApplication.willEnterForegroundNotification, object: nil)
}
@objc func restoreFromBackground() {
calendarView.collectionViewLayout.invalidateLayout()
}
Note: Setting UIRequiresFullScreen = YES resolves #1057 too.
An other approach to keep UIRequiresFullScreen = NO may be a combination of @tschmitz suggestion (that did not work for me) and a hack to resolve a rotation problem:
override func viewDidLoad() {
super.viewDidLoad()
NotificationCenter.default.addObserver(self, selector: #selector(restoreFromBackground), name: UIApplication.willEnterForegroundNotification, object: nil)
}
@objc func restoreFromBackground() {
calendarView.scrollDirection = .vertical
calendarView.scrollDirection = .horizontal
}