jonathantribouharet / JTCalendar

A customizable calendar view for iOS.
MIT License
2.76k stars 531 forks source link

JTCalendar UIConstraint issue on iOS 11 iPhone 7 #357

Closed MrJai closed 3 years ago

MrJai commented 6 years ago

Hi Everyone,

I have been using JTCalendar and it has been very helpful and an amazing utility. Thank you all for that. Recently with the launch of iOS 11, I have been facing this UI issue, first on Simulators and now iPhone7 running iOS 11. But it is working fine on rest of the devices, (iPhone 7 Plus, iPhone 6, etc.)

Your help and response will be highly appreciated, as it is a deal breaker and I have to submit my app before deadline.

Please refer to the screenshots.

Regards,

normal expected ui week normal expected ui ui constraint issue full ui constraint issue week

jonathantribouharet commented 6 years ago

Hi, have you check you didn't add some constraints or change something since before the update to iOS 11? You can try to debug the app to check the size of the views. It's seems like JTCalendarWeekDayView have an invalid height, try to force to set the height to 0 in different place like in 1viewDidAppear`.

MrJai commented 6 years ago

Thanks @jonathantribouharet I have not made any changes to constraints since I created this view. Moreover it is working fine for all other devices, but doing this only on iPhone 7 and on Simulators. And yes you are right, when in the start the weekDayView is being created, week mode is enabled and it is setting the number of weeks to 1. So in LayoutSubviews (JTCalendarPageView.m line 122) it is calculating WeekDayHeight to be 172 (line 137) self.frame.size.height / (_numberOfWeeksDisplayed + 1); But after the mode changes, this line never gets executed again, because now the weekDayHeight is never 0 again. I fixed it by adding the else part. but may be you can suggest something better.

CGFloat weekDayHeight = _weekDayView.frame.size.height; // Force use default height

        if(weekDayHeight == 0){ // Or use the same height than weeksViews
            weekDayHeight = self.frame.size.height / (_numberOfWeeksDisplayed + 1);
        }
        else
        {
            weekDayHeight = MIN(weekDayHeight, self.frame.size.height / (_numberOfWeeksDisplayed + 1));
        }
jonathantribouharet commented 6 years ago

When I read the code yesterday I see the same thing and I wonder how this code works until now. I think it's because the calendar is created in weekMode (with only one week visible), and I didn't test this case. I just add a setting pageViewWeekDaysViewAutomaticHeight you have to set it to true or YES (depending if you use swift or obj-c) and I think it will fix the problem. Update your pod to go to the 2.1.10 version.

MrJai commented 6 years ago

Thanks @jonathantribouharet, it worked.