Open InoruYang opened 7 years ago
你好,能否提供一个能重现的demo?
操作:在点击“选择框”->点击“日历”(一种情景为:点击“选择框”,然后快速点击“日历”,有几率闪退)
在 2017年1月7日,下午4:46,Wenchao Ding notifications@github.com 写道:
你好,能否提供一个能重现的demo?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/WenchaoD/FSCalendar/issues/541#issuecomment-271071390, or mute the thread https://github.com/notifications/unsubscribe-auth/AI3HXZAc-nAwiAPpUjUTrzzlL0RTlXl2ks5rP1DagaJpZM4LdTeE.
The same for me by quickly showing on the screen of the calendar (in an app with tab bar controller). Everything ok by waiting some seconds.
0 -[UICollectionViewData _setLayoutAttributes:atGlobalItemIndex:]: 1 __45-[UICollectionViewData validateLayoutInRect:]_block_invoke: 2 -[UICollectionViewData validateLayoutInRect:]: 3 -[UICollectionView layoutSubviews]:
Version 2.6.0 (using CocoaPods)
Edit:
It seems that this helps:
DispatchQueue.main.async {
self.calendar.collectionViewLayout.invalidateLayout()
self.calendar.collectionView.collectionViewLayout.invalidateLayout()
self.calendar.reloadData()
}
@nihilenz tha ,Where should I use this code
@IceSnow Forget it, it does not always help
Is there someone who can provide a demo project to reproduce this?
This is code that runs inside viewDidLoad for me where I add FSCalendar to existing UIStackView. calendarView variable is a private instance variable. It doesn't happen all the time, around 40-50% of the time.
// Calendar
calendarView = [[FSCalendar alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth(self.view.frame), 300)];
calendarView.dataSource = self;
calendarView.delegate = self;
calendarView.scope = FSCalendarScopeMonth;
calendarView.scopeGesture.enabled = false;
calendarView.allowsMultipleSelection = true;
calendarView.scrollEnabled = true;
calendarView.clipsToBounds = true;
calendarView.backgroundColor = [[UIColor alloc] initWithRed:0.608 green:0.347 blue:0.714 alpha:1];
calendarView.appearance.headerTitleColor = [UIColor whiteColor];
calendarView.appearance.weekdayTextColor = [UIColor whiteColor];
calendarView.appearance.titleDefaultColor = [UIColor whiteColor];
calendarView.appearance.eventSelectionColor = [UIColor whiteColor];
calendarView.appearance.selectionColor = [UIColor whiteColor];
[calendarView registerClass:FSCalendarCell.self forCellReuseIdentifier:@"cell"];
// Calendar dates
now = calendarView.today; // Save today
calendarView.today = nil; // Hide the today circle
NSDateComponents *components = [gregorian components:NSCalendarUnitYear | NSCalendarUnitMonth | NSCalendarUnitWeekOfYear | NSCalendarUnitWeekday fromDate:now];
NSUInteger weekdayToday = [components weekday];
NSInteger daysToFriday = (13 - weekdayToday) % 7;
startDate = [gregorian dateByAddingUnit:NSCalendarUnitDay value:daysToFriday toDate:now options:0];
endDate = [gregorian dateByAddingUnit:NSCalendarUnitDay value:daysToFriday + 2 toDate:now options:0];
NSDate *current = startDate;
while ([current compare:endDate] != NSOrderedDescending) {
[calendarView selectDate:current];
current = [gregorian dateByAddingUnit:NSCalendarUnitDay value:1 toDate:current options:0];
}
constraint = [NSLayoutConstraint constraintWithItem:calendarView attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeHeight multiplier:1.0 constant:300];
[constraint setPriority:999]; // Needs to be less than 1000 not to conflict with UISV-hiding constraint inside stackView
[constraint setIdentifier:@"calendarViewHeight"];
[calendarView addConstraint:constraint];
[calendarView layoutSubviews];
[stackView insertArrangedSubview:calendarView atIndex:0];
calendarView.hidden = true;
@WenchaoD 我也遇到这个BUG过,后来测试发现selectDate在必须要在VC的viewDidAppear及其以后,在更早的生命周期(比方viewDidLoad)就会随机奔溃。
Looks like this StackOverflow article may be relevant:
T
A brief bug description: 日历控件几率闪退
Stack trace:
UIKit
-[UICollectionViewData _setLayoutAttributes:atGlobalItemIndex:]: 0x18da1a5e8 <+0>: stp d15, d14, [sp, #-160]! 0x18da1a5ec <+4>: stp d13, d12, [sp, #16] 0x18da1a5f0 <+8>: stp d11, d10, [sp, #32] 0x18da1a5f4 <+12>: stp d9, d8, [sp, #48] 0x18da1a5f8 <+16>: stp x28, x27, [sp, #64] 0x18da1a5fc <+20>: stp x26, x25, [sp, #80] 0x18da1a600 <+24>: stp x24, x23, [sp, #96] 0x18da1a604 <+28>: stp x22, x21, [sp, #112] 0x18da1a608 <+32>: stp x20, x19, [sp, #128] 0x18da1a60c <+36>: stp x29, x30, [sp, #144] 0x18da1a610 <+40>: add x29, sp, #144 ; =144 0x18da1a614 <+44>: sub sp, sp, #16 ; =16 0x18da1a618 <+48>: mov x21, x3 0x18da1a61c <+52>: mov x20, x0 0x18da1a620 <+56>: mov x0, x2 0x18da1a624 <+60>: bl 0x186554090 ; objc_retain 0x18da1a628 <+64>: mov x22, x0 0x18da1a62c <+68>: adrp x8, 124607 0x18da1a630 <+72>: ldrsw x19, [x8, #1164] 0x18da1a634 <+76>: ldr x8, [x20, x19] -> 0x18da1a638 <+80>: ldr x0, [x8, w21, sxtw #3] 0x18da1a63c <+84>: cmp x0, x22 0x18da1a640 <+88>: b.eq 0x18da1a86c ; <+644> 0x18da1a644 <+92>: sxtw x21, w21 0x18da1a648 <+96>: str xzr, [x8, x21, lsl #3] 0x18da1a64c <+100>: bl 0x186554150 ; objc_release 0x18da1a650 <+104>: adrp x8, 124531 0x18da1a654 <+108>: ldr x1, [x8, #2176] 0x18da1a658 <+112>: mov x0, x22 0x18da1a65c <+116>: bl 0x18654ef60 ; objc_msgSend 0x18da1a660 <+120>: ldr x9, [x20, x19] 0x18da1a664 <+124>: ldr x8, [x9, x21, lsl #3] 0x18da1a668 <+128>: str x0, [x9, x21, lsl #3] 0x18da1a66c <+132>: mov x0, x8 0x18da1a670 <+136>: bl 0x186554150 ; objc_release 0x18da1a674 <+140>: cbz x22, 0x18da1a86c ; <+644> 0x18da1a678 <+144>: adrp x8, 124531 0x18da1a67c <+148>: ldr x1, [x8, #1792] 0x18da1a680 <+152>: mov x0, x22 0x18da1a684 <+156>: str x22, [sp, #8] 0x18da1a688 <+160>: bl 0x18654ef60 ; objc_msgSend 0x18da1a68c <+164>: mov.16b v8, v0 0x18da1a690 <+168>: mov.16b v9, v1 0x18da1a694 <+172>: mov.16b v10, v2 0x18da1a698 <+176>: mov.16b v11, v3 0x18da1a69c <+180>: bl 0x1890d37b0 ; CGRectGetMinX 0x18da1a6a0 <+184>: mov.16b v12, v0 0x18da1a6a4 <+188>: adrp x27, 124581 0x18da1a6a8 <+192>: ldr x24, [x27, #3048] 0x18da1a6ac <+196>: adrp x28, 124536 0x18da1a6b0 <+200>: ldr x25, [x28, #440] 0x18da1a6b4 <+204>: adrp x19, 129517 0x18da1a6b8 <+208>: fmov d14, #-1.00000000 0x18da1a6bc <+212>: mov x22, x25 0x18da1a6c0 <+216>: mov x23, x24 0x18da1a6c4 <+220>: b 0x18da1a718 ; <+304> 0x18da1a6c8 <+224>: mov.16b v0, v8 0x18da1a6cc <+228>: mov.16b v1, v9 0x18da1a6d0 <+232>: mov.16b v2, v10 0x18da1a6d4 <+236>: mov.16b v3, v11 0x18da1a6d8 <+240>: bl 0x1890d3884 ; CGRectGetMaxY 0x18da1a6dc <+244>: fadd d1, d0, d14 0x18da1a6e0 <+248>: mov.16b v0, v12 0x18da1a6e4 <+252>: mov x0, x20 0x18da1a6e8 <+256>: mov x1, x24 0x18da1a6ec <+260>: bl 0x18654ef60 ; objc_msgSend 0x18da1a6f0 <+264>: mov x29, x29 0x18da1a6f4 <+268>: bl 0x18655648c ; objc_retainAutoreleasedReturnValue 0x18da1a6f8 <+272>: mov x26, x0 0x18da1a6fc <+276>: mov x1, x25 0x18da1a700 <+280>: mov x2, x21 0x18da1a704 <+284>: bl 0x18654ef60 ; objc_msgSend 0x18da1a708 <+288>: mov x0, x26 0x18da1a70c <+292>: bl 0x186554150 ; objc_release 0x18da1a710 <+296>: ldr d0, [x19, #520] 0x18da1a714 <+300>: fadd d12, d12, d0 0x18da1a718 <+304>: mov.16b v0, v8 0x18da1a71c <+308>: mov.16b v1, v9 0x18da1a720 <+312>: mov.16b v2, v10 0x18da1a724 <+316>: mov.16b v3, v11 0x18da1a728 <+320>: bl 0x1890d382c ; CGRectGetMinY 0x18da1a72c <+324>: ldr d2, [x19, #520] 0x18da1a730 <+328>: fdiv d1, d12, d2 0x18da1a734 <+332>: frintm d1, d1 0x18da1a738 <+336>: fmul d3, d2, d1 0x18da1a73c <+340>: fdiv d0, d0, d2 0x18da1a740 <+344>: frintm d0, d0 0x18da1a744 <+348>: fmul d1, d2, d0 0x18da1a748 <+352>: mov.16b v0, v3 0x18da1a74c <+356>: mov.16b v3, v2 0x18da1a750 <+360>: mov.16b v4, v8 0x18da1a754 <+364>: mov.16b v5, v9 0x18da1a758 <+368>: mov.16b v6, v10 0x18da1a75c <+372>: mov.16b v7, v11 0x18da1a760 <+376>: bl 0x1890d439c ; CGRectIntersectsRect 0x18da1a764 <+380>: mov.16b v0, v8 0x18da1a768 <+384>: mov.16b v1, v9 0x18da1a76c <+388>: mov.16b v2, v10 0x18da1a770 <+392>: mov.16b v3, v11 0x18da1a774 <+396>: cbz w0, 0x18da1a818 ; <+560> 0x18da1a778 <+400>: bl 0x1890d382c ; CGRectGetMinY 0x18da1a77c <+404>: mov.16b v13, v0 0x18da1a780 <+408>: ldr x23, [x27, #3048] 0x18da1a784 <+412>: ldr x22, [x28, #440] 0x18da1a788 <+416>: b 0x18da1a7c8 ; <+480> 0x18da1a78c <+420>: mov.16b v0, v12 0x18da1a790 <+424>: mov.16b v1, v13 0x18da1a794 <+428>: mov x0, x20 0x18da1a798 <+432>: mov x1, x23 0x18da1a79c <+436>: bl 0x18654ef60 ; objc_msgSend 0x18da1a7a0 <+440>: mov x29, x29 0x18da1a7a4 <+444>: bl 0x18655648c ; objc_retainAutoreleasedReturnValue 0x18da1a7a8 <+448>: mov x26, x0 0x18da1a7ac <+452>: mov x1, x22 0x18da1a7b0 <+456>: mov x2, x21 0x18da1a7b4 <+460>: bl 0x18654ef60 ; objc_msgSend 0x18da1a7b8 <+464>: mov x0, x26 0x18da1a7bc <+468>: bl 0x186554150 ; objc_release 0x18da1a7c0 <+472>: ldr d0, [x19, #520] 0x18da1a7c4 <+476>: fadd d13, d13, d0 0x18da1a7c8 <+480>: mov.16b v0, v8 0x18da1a7cc <+484>: mov.16b v1, v9 0x18da1a7d0 <+488>: mov.16b v2, v10 0x18da1a7d4 <+492>: mov.16b v3, v11 0x18da1a7d8 <+496>: bl 0x1890d37b0 ; CGRectGetMinX 0x18da1a7dc <+500>: ldr d2, [x19, #520] 0x18da1a7e0 <+504>: fdiv d0, d0, d2 0x18da1a7e4 <+508>: frintm d0, d0 0x18da1a7e8 <+512>: fmul d0, d2, d0 0x18da1a7ec <+516>: fdiv d1, d13, d2 0x18da1a7f0 <+520>: frintm d1, d1 0x18da1a7f4 <+524>: fmul d1, d2, d1 0x18da1a7f8 <+528>: mov.16b v3, v2 0x18da1a7fc <+532>: mov.16b v4, v8 0x18da1a800 <+536>: mov.16b v5, v9 0x18da1a804 <+540>: mov.16b v6, v10 0x18da1a808 <+544>: mov.16b v7, v11 0x18da1a80c <+548>: bl 0x1890d439c ; CGRectIntersectsRect 0x18da1a810 <+552>: cbnz w0, 0x18da1a78c ; <+420> 0x18da1a814 <+556>: b 0x18da1a6c8 ; <+224> 0x18da1a818 <+560>: bl 0x1890d3804 ; CGRectGetMaxX 0x18da1a81c <+564>: fadd d12, d0, d14 0x18da1a820 <+568>: mov.16b v0, v8 0x18da1a824 <+572>: mov.16b v1, v9 0x18da1a828 <+576>: mov.16b v2, v10 0x18da1a82c <+580>: mov.16b v3, v11 0x18da1a830 <+584>: bl 0x1890d3884 ; CGRectGetMaxY 0x18da1a834 <+588>: fadd d1, d0, d14 0x18da1a838 <+592>: mov.16b v0, v12 0x18da1a83c <+596>: mov x0, x20 0x18da1a840 <+600>: mov x1, x23 0x18da1a844 <+604>: bl 0x18654ef60 ; objc_msgSend 0x18da1a848 <+608>: mov x29, x29 0x18da1a84c <+612>: bl 0x18655648c ; objc_retainAutoreleasedReturnValue 0x18da1a850 <+616>: mov x20, x0 0x18da1a854 <+620>: mov x1, x22 0x18da1a858 <+624>: mov x2, x21 0x18da1a85c <+628>: bl 0x18654ef60 ; objc_msgSend 0x18da1a860 <+632>: mov x0, x20 0x18da1a864 <+636>: bl 0x186554150 ; objc_release 0x18da1a868 <+640>: ldr x22, [sp, #8] 0x18da1a86c <+644>: mov x0, x22 0x18da1a870 <+648>: sub sp, x29, #144 ; =144 0x18da1a874 <+652>: ldp x29, x30, [sp, #144] 0x18da1a878 <+656>: ldp x20, x19, [sp, #128] 0x18da1a87c <+660>: ldp x22, x21, [sp, #112] 0x18da1a880 <+664>: ldp x24, x23, [sp, #96] 0x18da1a884 <+668>: ldp x26, x25, [sp, #80] 0x18da1a888 <+672>: ldp x28, x27, [sp, #64] 0x18da1a88c <+676>: ldp d9, d8, [sp, #48] 0x18da1a890 <+680>: ldp d11, d10, [sp, #32] 0x18da1a894 <+684>: ldp d13, d12, [sp, #16] 0x18da1a898 <+688>: ldp d15, d14, [sp], #160 0x18da1a89c <+692>: b 0x186554150 ; objc_release `Integration method:
manually
Full steps to reproduce:迅速打开关闭日历(又几率显示时崩溃)
Device modal and iOS version.
iPhone 6s 6 6plus 6s plus iOS9.1 9.2 9.3 iOS 10.2
Xcode version.
Xcode 8.1
FSCalendar version.
FSCalenda 2.7.0
Does this happen in the demo project? Which one? Or a link to another demo project. 自定义显示方式