Hello, Jay. :)
I don't know if I'm missing something, but I'm trying to get my app to support multiple orientations and the calendar won't update properly when the device is rotated.
Here's how it looks at first:

Then I rotate the device and:

When I scroll to a different date this appears to be fixed, so I'm scrolling at didRotate():

But even if it appears to be fixed at first, when I scroll to a different month and try to select a date the calendar breaks again. Any ideas?
Alright, i'll check this out later
Will check it once i finish work.
One thing, what is your scrollDirection?
And is it happening on 6.1.2? or masterBranch?
Horizontal. And it's happening on master. I didn't check 6.1.2, I assumed it's the same in that regard.
OK. Back. I was working on orientation updates this morning. Just made a push to master branch.
Let me know if its still hapening
Uhm, it looks like it's still the same here. :/
I cloned the master branch and gave it a try in the demo app. The problem doesn't always happen, I'm not sure why… but it does happen:

To reproduce you can start the sample app, select a date and do cmd-right (the command key and the right arrow key together) followed by cmd-left. If it doesn't happen, scroll to the next month, select a different date and do it again. And so on, keep scrolling and changing the orientation, eventually it breaks. In my app it happens every time, in the example it only happens sometimes, I'm not sure why.
ok. checking this now.
Do i do the cmd-r and the cmd-l quickly? or does that not matter
-> https://gitter.im/patchthecode/JTAppleCalendar
If youre free
One thing though, that last image you posted is expected. One header is bigger than the other, unless im missing something?
I'm there.
But it doesn't matter if the cmd-r/cmd-l are done quickly… and what's unexpected about the image is that the calendar would settle showing half of each month at the same time, isn't it?
In this function, can you place a print statement at the end link this?
func setMinVisibleDate() { // jt101 for setting proposal
let minIndices = minimumVisibleIndexPaths()
switch (minIndices.headerIndex, minIndices.cellInfo.indexPath) {
case (.some(let path), nil):
lastIndexOffset = (path, UICollectionElementCategory.supplementaryView)
case (nil, .some(let path)):
lastIndexOffset = (path, UICollectionElementCategory.cell)
case (.some(let hPath), (.some(let cPath))):
if hPath <= cPath {
lastIndexOffset = (hPath, UICollectionElementCategory.supplementaryView)
} else {
lastIndexOffset = (cPath, UICollectionElementCategory.cell)
}
default:
break
}
print(lastIndexOffset)
}
It should be saving the last index right before orientation change.
If it is nil, then something is wrong.
In my app, you mean? I'm using Carthage, so I'll have to include the source
directly. Now I'm going to bed, it's 3 am here and I'll have to be up
early, but I can do it tomorrow if that's alright. How about the demo app,
though? Did it work there?
Em ter, 21 de fev de 2017 às 02:53, JTAppleCalendar <
[email protected]> escreveu:
In this function, can you place a print statement at the end link this?
func setMinVisibleDate() { // jt101 for setting proposal let minIndices = minimumVisibleIndexPaths()
switch (minIndices.headerIndex, minIndices.cellInfo.indexPath) {
case (.some(let path), nil):
lastIndexOffset = (path, UICollectionElementCategory.supplementaryView)
case (nil, .some(let path)):
lastIndexOffset = (path, UICollectionElementCategory.cell)
case (.some(let hPath), (.some(let cPath))):
if hPath <= cPath {
lastIndexOffset = (hPath, UICollectionElementCategory.supplementaryView)
} else {
lastIndexOffset = (cPath, UICollectionElementCategory.cell)
}
default:
break
}
print(lastIndexOffset)
}It should be saving the last index right before orientation change.
If it is nil, then something is wrong.—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/patchthecode/JTAppleCalendar/issues/316#issuecomment-281252017,
or mute the thread
https://github.com/notifications/unsubscribe-auth/APFMKt48JrPZHuRLqkdYNPQo-MYCENTJks5renvNgaJpZM4MGsRi
.
Yes i am seeing the error there. But I know the reason why it is happening there now.
I just want to confirm if the error I am getting is the same that you are getting.
Hey, sorry for the delay.
The problem is still happening with the latest commit. I did what you said and the value of lastIndexOffset is not nil when I change the orientation. Rather, if I just go cmd-r, cmd-l, cmd-r, cmd-l, the value is different almost every time the orientation changes:
Optional(([54, 1], __C.UICollectionElementCategory))
Optional(([54, 1], __C.UICollectionElementCategory))
Optional(([52, 6], __C.UICollectionElementCategory))
Optional(([54, 0], __C.UICollectionElementCategory))
Optional(([54, 4], __C.UICollectionElementCategory))
Optional(([54, 4], __C.UICollectionElementCategory))
Optional(([53, 2], __C.UICollectionElementCategory))
Ok. I'll have to share screen with you one last time after work.
Mine does not behave like this.
Will contact you again in about 3.5 hrs
No problem, thanks for your help. :)
made changes -> https://github.com/patchthecode/JTOrientationTest
let me know
Ok, I'll give it a try soon... but I just took a look at your commit and:
guard let completionHandler = completionHandler else { return }
self.completionHandler = nil
completionHandler()
Why call completionHandler() right after setting it to nil? And why the guard let in the first place then?
By the way, I don't even know what's happening there, I just took a quick glance at the code, but I think you could replace those three lines with:
completionHandler?()
self.completionHandler = nil
I did this as safety.
Let me know if my logic is wrong.
class CustomCollectionView: UICollectionView {
var completionHandler: (() -> Void)? = nil
override func layoutSubviews() {
super.layoutSubviews() // Layout subviews called
completionHandler?() // user had a completion handler, that in-turn again calls layoutSubviews. Loop?
self.completionHandler = nil
}
}
VS
class CustomCollectionView: UICollectionView {
var completionHandler: (() -> Void)? = nil
override func layoutSubviews() {
super.layoutSubviews() // Layout subviews called
guard let completionHandler = completionHandler else { return } // If completion handler = nil, then return. If not, then save it in a local variable
self.completionHandler = nil // Set the class completion handler to nil
completionHandler() // Call the local version. If layoutSubviews is again called, then it will be nil
}
}
Let me know if my logic is incorrect
Oh, ok, I just got the local and global versions mixed up, sorry. I'll try the latest version now.
Alright, it's looking good so far!
Ok i will begin making the code neater.
And begin migrating changes to master.
Awesome, thanks. I just noticed another problem, I think it's better if I open another issue, though, I'll do that now.
Fixed on latest master branch.
closing.
Hi, I am having the same problem. I followed the guide to create the calendar with ipad. Here are the screen shots of it.
Portrait

Landscape:

I am guessing you need to call the following whenever the orientation changes but I don't where to add it.
calendarview.collectionViewLayout.invalidateLayout()
Also, it is not exposed as api.
I am using this version of JTAppleCalendar
pod 'JTAppleCalendar', '~> 6.1'
Thanks
@namuthan can you try updating to version 6.1.6 ?
If you already have 6.1.6 then, join me here -> https://gitter.im/patchthecode/JTAppleCalendar
I tried the 6.1.6 version, and the same issue persist.
@namuthan
JTAppleCalendarExample.zip
I've updated your project with version 7.0
Does it work as expected?
It does work as expected 👍