Closed YanSte closed 8 years ago
Same problem
i try the try catch form but not work
Can you give a bit more context ? I cant reproduce on samples. Are you adding the parallax header to a UITableView ? I've made some changes recently that may have introduce this bug.
This does not work ? :
- (void)willMoveToSuperview:(UIView *)newSuperview {
@try {
[self.superview removeObserver:self.parent forKeyPath:NSStringFromSelector(@selector(contentOffset)) context:kMXParallaxHeaderKVOContext];
} @catch (NSException *exception) {}
}
Can you try this ? :
- (void)willMoveToSuperview:(UIView *)newSuperview {
if (self.parent) {
[self.superview removeObserver:self.parent forKeyPath:NSStringFromSelector(@selector(contentOffset)) context:kMXParallaxHeaderKVOContext];
}
}
- (void)didMoveToSuperview {
if (self.parent) {
[self.superview addObserver:self.parent
forKeyPath:NSStringFromSelector(@selector(contentOffset))
options:NSKeyValueObservingOptionNew
context:kMXParallaxHeaderKVOContext];
}
}
Thanks for the report.
same problem here
@maxep the try/catch doesn't fix.
The second proposition give this :
same problem here
leave the view
libc++abi.dylib: terminate_handler unexpectedly threw an exception
Is v0.5.0 has this issue ? are you adding a parallax header to a table view?
@maxep yes, this is a tableview from me, with static cell. And the app crash when I pop to the view before (UInavigationBar back button).
on the version v0.5.0 is working well
2016-06-20 14:54 GMT-03:00 Léo Derbois notifications@github.com:
@maxep https://github.com/maxep yes, this is a tableview from me, with static cell. And the app crash when I pop to the view before (UInavigationBar back button).
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/maxep/MXParallaxHeader/issues/28#issuecomment-227218175, or mute the thread https://github.com/notifications/unsubscribe/ALLOfxCFXh9eaR6A8gmSs5ZOvseOW5ZEks5qNtPFgaJpZM4I11FO .
@maxep I just tried like this : pod 'MXParallaxHeader','= 0.5.0'
And the crash was not in this release.
- (void)willMoveToSuperview:(UIView *)newSuperview {
[self.superview removeObserver:self.parent forKeyPath:NSStringFromSelector(@selector(contentOffset)) context:kMXParallaxHeaderKVOContext];
}
- (void)setTableHeaderViewFrame:(CGRect)frame {
//Create a table header view that will raise KVO
MXParallaxView *headerView = [[MXParallaxView alloc] initWithFrame:frame];
headerView.parent = self;
[headerView addSubview:self.contentView];
[(UITableView *)self.scrollView setTableHeaderView:headerView];
[headerView setNeedsLayout];
}
Conflict between the 2 methods above.
self.contentView's class is MXParallaxView
[headerView addSubview:self.contentView]; self.contentView's superView class also is MXParallaxView.
So [self.superview removeObserver:self.parent forKeyPath:NSStringFromSelector(@selector(contentOffset)) context:kMXParallaxHeaderKVOContext]; make crash.
My Code:
- (void)willMoveToSuperview:(UIView *)newSuperview {
if ([self.superview isKindOfClass:[UIScrollView class]]) {
[self.superview removeObserver:self.parent forKeyPath:NSStringFromSelector(@selector(contentOffset)) context:kMXParallaxHeaderKVOContext];
}
}
- (void)didMoveToSuperview {
if ([self.superview isKindOfClass:[UIScrollView class]]) {
[self.superview addObserver:self.parent
forKeyPath:NSStringFromSelector(@selector(contentOffset))
options:NSKeyValueObservingOptionNew
context:kMXParallaxHeaderKVOContext];
}
}
Good fix, but are there any plans of getting this into the next release of MXSegmentedPager?
Fix by #31
Crash on
this is my error : Terminating app due to uncaught exception 'NSRangeException', reason: 'Cannot remove an observer <(null) 0x0> for the key path "contentOffset" from <MXParallaxView 0x1569c8860> because it is not registered as an observer.' *\ First throw call stack: (0x180a42db0 0x1800a7f80 0x180a42cf8 0x1813590a8 0x181358b84 0x181358ac8 0x100ddaf80 0x185eb4014 0x185b994a0 0x185b9c924 0x181396cb0 0x1800c1ae8 0x1809209fc 0x1809f6bc0 0x180920c50 0x182208088 0x185c0a088 0x100281a58 0x1804be8b8) libc++abi.dylib: terminating with uncaught exception of type NSException