JTAppleCalendar icon indicating copy to clipboard operation
JTAppleCalendar copied to clipboard

ios13 compatibility

Open boborbt opened this issue 6 years ago • 19 comments

(Required) Version Number: 8.0.1 (and master)

Description

There it seems to be some strange interaction between reusable cells and iOS 13. Is there any chance there is something to be changed in the code to support iOS 13? Am I the only one to experience these problems?

The behaviour I'm experiencing is the following one: I am changing the appearance of cells depending on whether the cell represents a date:

  • is in the current month
  • is a day before today in the first case the cell contents will be hidden; in the second case the text will appear in gray instead of black.

On the iOS 12 simulator everything is fine. On the iOS 13 simulator colors and hidden cells do not seem to work properly (they seems to show some random behaviour). My hypothesis is that something changed in how reusable cells are used and (maybe) there is something new I have to do to support this behaviour properly.

Steps To Reproduce

I have not at hand a sample project. But I can share my code if useful.

Expected Behavior

Additional Context

boborbt avatar Sep 14 '19 10:09 boborbt

hmm. I did not notice any of those things. Maybe a sample app can help me?

patchthecode avatar Sep 16 '19 11:09 patchthecode

Hi @patchthecode, I've added you to the github project for the app I'm testing. It is not really a "sample app", but it is the best I can do at the moment.

You can find the calendar delegates in the file: MainViewController+CalendarDelegates.swift; the view I'm using for the calendar cells is in DayCellView.swift.

Note: the project is Carthage based.

boborbt avatar Sep 16 '19 13:09 boborbt

Hey, just getting back to this. Had a busy week. What is the link to the project? I didnt see any notifications. If its a private project, can you send me a link at [email protected]?

patchthecode avatar Sep 26 '19 09:09 patchthecode

Hey, just getting back to this. Had a busy week. What is the link to the project? I didnt see any notifications. If its a private project, can you send me a link at [email protected]?

Hi Jay, did you receive the mail?

boborbt avatar Sep 29 '19 14:09 boborbt

Sorry for the late reply. Will check! thanks.

patchthecode avatar Sep 30 '19 17:09 patchthecode

Hi @patchthecode, do not waste your time. I just realised I was working on code that has not been yet committed. You would not be able to compile the project. I need to do some work on that code before committing it. I'll do the work and if at the end the problem persist I will try to bother you again.

Once again for your generous offer to look through my code.

All the best.

boborbt avatar Oct 01 '19 15:10 boborbt

i am not bothered. I just got a little tied up trying to do multiple projects 😅.

If you still have the issue, then re-open this, i'll take a look

patchthecode avatar Oct 01 '19 16:10 patchthecode

Hi Jay,    I didn’t mean to imply you were bothered. This is not my first language so maybe it came off differently to what I intended.

I know very well the efforts you are willing to put to help everyone. I really only meant that I was going to fix things as best as I could before wasting your time due to problems in my code/repository.

Have a good day, Roberto

boborbt avatar Oct 01 '19 16:10 boborbt

Awesome thanks man.

patchthecode avatar Oct 01 '19 16:10 patchthecode

Here I am. Cleaned up the project and fixed the repository. I still have the problem unfortunately.

I'm reopening the issue. Also, to simplify your work I have uploaded a .zip containing everything you need to look into the problem (if I did everything correctly, Carthage and other dependencies should already be there, if you open the workspace and just hit build you should be good to go).

I removed the .git directory to make the archive smaller. You still have access to the repository via GitHub if you need it.

I'll be mailing the download link to your personal mail in a second.

Thanks in advance for your help.

boborbt avatar Oct 02 '19 09:10 boborbt

Try to implement the prepareForReuse() function in the cellView like this:

        override func prepareForReuse() {
		resetAllTheUIWithBasicStyle()
	}

I had the same problem and fixed with this.

AndreaMiotto avatar Oct 22 '19 09:10 AndreaMiotto

Ok, this definitely seems to be a change in iOS 13. Thanks for taking a look @AndreaMiotto I got tied up with a number of projects to take a look in a timely manner.

Since this problem never existed prior to iOS13 I think I should force users to implement this function, and also update the tutorials. Marking this with update flag.

patchthecode avatar Oct 22 '19 11:10 patchthecode

Try to implement the prepareForReuse() function in the cellView like this:

        override func prepareForReuse() {
		resetAllTheUIWithBasicStyle()
	}

I had the same problem and fixed with this.

I've tried to override prepareForReuse so to reset all UI style so to match the "clean" state. I can see that the function is called, but this makes no difference in my case. Am I missing something? I've implemented it in my JTACDayCell subclass.

boborbt avatar Oct 24 '19 13:10 boborbt

I'll be free tommorrow. I'll try it on my sample project. If @AndreaMiotto 's suggestion works, then i'll post a fix.

patchthecode avatar Oct 24 '19 13:10 patchthecode

Try to implement the prepareForReuse() function in the cellView like this:

        override func prepareForReuse() {
		resetAllTheUIWithBasicStyle()
	}

I had the same problem and fixed with this.

I've tried to override prepareForReuse so to reset all UI style so to match the "clean" state. I can see that the function is called, but this makes no difference in my case. Am I missing something? I've implemented it in my JTACDayCell subclass.

Can you put here your reset code and you style code for the cell?

AndreaMiotto avatar Oct 25 '19 15:10 AndreaMiotto

Can you put here your reset code and you style code for the cell?

Sure, sorry for the delay: https://gist.github.com/boborbt/d1aca6c8fcd00a10db5ffc4aea3038e1

Thanks in advance.

boborbt avatar Oct 29 '19 09:10 boborbt

@patchthecode any news about this issue? I've tried to investigate more about why this happens, but I really cannot figure out anything useful...

An additional piece of information that might be helpful: the erroneous appearance gets corrected when in the interface I select the cell.

boborbt avatar Nov 08 '19 09:11 boborbt

Hi Jay, I found the problem. If you look at my code (I shared the relevant class in gist https://gist.github.com/boborbt/d1aca6c8fcd00a10db5ffc4aea3038e1), I updated the appearance of cells using the following function:

private func updateMarksColor() {
        switch colorEmphasis {
        case .normal:
            self.alpha = 1.0
        case .dim:
            self.alpha = 0.3
        case .hidden:
            self.alpha = 0.0
        }
    }

The problem appears to be related to the fact that for whatever reason in iOS 13 the alpha property on the JTACDayCell seems to be not restored correctly when reusing cells (this is my best understanding of the matter).

I fixed the problem by setting the alpha value of the relevant part of the cells instead of setting it for the whole cell. The new code looks is:

    private func updateMarksColor() {
        switch colorEmphasis {
        case .normal:
            self.label.alpha = 1.0
            self.marksDisplayView.alpha = 1.0
        case .dim:
            self.label.alpha = 0.3
            self.marksDisplayView.alpha = 0.3
        case .hidden:
            self.label.alpha = 0.0
            self.marksDisplayView.alpha = 0.0
        }
    }

and it works well.

Hope this helps. I guess you will want to close this issue, I will not do it myself since you might want to investigate further the issue.

boborbt avatar Nov 26 '19 15:11 boborbt

yea.. i keep saying that i will look. but i am so caught up on this project, that i do not want to make any further promises.

I am still investigating SwiftUI and just getting used to it. Sorry I couldnt get to this sooner. I will leave this open because i will get to it.

patchthecode avatar Nov 27 '19 00:11 patchthecode