FSCalendar icon indicating copy to clipboard operation
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

Open akring opened this issue 7 years ago • 6 comments

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

akring avatar Aug 29 '17 09:08 akring

Did you find any solution?

mureatencio avatar Nov 15 '17 23:11 mureatencio

Try to set "UIRequiresFullScreen" in project settings. iPad supports split screen option, it seems some screen update happens after application changes state.

redcapua avatar Nov 22 '17 12:11 redcapua

Yeah, possibly there is a screen update, but my app should support split screen. Any other idea?

mureatencio avatar Nov 22 '17 12:11 mureatencio

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()
}

tschmitz avatar Mar 06 '19 21:03 tschmitz

Note: Setting UIRequiresFullScreen = YES resolves #1057 too.

twilightDD avatar Feb 16 '21 17:02 twilightDD

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
}

twilightDD avatar Feb 16 '21 17:02 twilightDD