Merge pull request #117 from gfzabarino/master
Scroll view started with wrong content offset on some occasions
This commit is contained in:
commit
a1c57da65f
|
|
@ -11,6 +11,6 @@
|
||||||
|
|
||||||
@interface UIScrollView (Helpers)
|
@interface UIScrollView (Helpers)
|
||||||
|
|
||||||
- (void)tly_setInsets:(UIEdgeInsets)contentInsets preserveOffset:(BOOL)preserveOffset;
|
- (void)tly_setInsets:(UIEdgeInsets)contentInsets;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
||||||
|
|
@ -11,9 +11,9 @@
|
||||||
@implementation UIScrollView (Helpers)
|
@implementation UIScrollView (Helpers)
|
||||||
|
|
||||||
// Modify contentInset and scrollIndicatorInsets
|
// Modify contentInset and scrollIndicatorInsets
|
||||||
- (void)tly_setInsets:(UIEdgeInsets)contentInsets preserveOffset:(BOOL)preserveOffset
|
- (void)tly_setInsets:(UIEdgeInsets)contentInsets
|
||||||
{
|
{
|
||||||
if (preserveOffset && contentInsets.top != self.contentInset.top)
|
if (!self.isDragging && !self.isDecelerating && contentInsets.top != self.contentInset.top)
|
||||||
{
|
{
|
||||||
CGFloat offsetDelta = contentInsets.top - self.contentInset.top;
|
CGFloat offsetDelta = contentInsets.top - self.contentInset.top;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,6 @@
|
||||||
@property (nonatomic, weak) UIScrollView *scrollView;
|
@property (nonatomic, weak) UIScrollView *scrollView;
|
||||||
@property (nonatomic, weak) TLYShyViewController *parent;
|
@property (nonatomic, weak) TLYShyViewController *parent;
|
||||||
|
|
||||||
- (CGFloat)updateLayoutIfNeeded:(BOOL)intelligently;
|
- (CGFloat)updateLayoutIfNeeded;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
||||||
|
|
@ -14,10 +14,10 @@
|
||||||
|
|
||||||
- (void)offsetCenterBy:(CGPoint)deltaPoint
|
- (void)offsetCenterBy:(CGPoint)deltaPoint
|
||||||
{
|
{
|
||||||
[self updateLayoutIfNeeded:NO];
|
[self updateLayoutIfNeeded];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (CGFloat)updateLayoutIfNeeded:(BOOL)intelligently
|
- (CGFloat)updateLayoutIfNeeded
|
||||||
{
|
{
|
||||||
if (self.scrollView.contentSize.height < FLT_EPSILON
|
if (self.scrollView.contentSize.height < FLT_EPSILON
|
||||||
&& ([self.scrollView isKindOfClass:[UITableView class]]
|
&& ([self.scrollView isKindOfClass:[UITableView class]]
|
||||||
|
|
@ -35,7 +35,7 @@
|
||||||
if (normalizedY > -FLT_EPSILON && !UIEdgeInsetsEqualToEdgeInsets(insets, self.scrollView.contentInset))
|
if (normalizedY > -FLT_EPSILON && !UIEdgeInsetsEqualToEdgeInsets(insets, self.scrollView.contentInset))
|
||||||
{
|
{
|
||||||
CGFloat delta = insets.top - self.scrollView.contentInset.top;
|
CGFloat delta = insets.top - self.scrollView.contentInset.top;
|
||||||
[self.scrollView tly_setInsets:insets preserveOffset:intelligently];
|
[self.scrollView tly_setInsets:insets];
|
||||||
|
|
||||||
return delta;
|
return delta;
|
||||||
}
|
}
|
||||||
|
|
@ -46,7 +46,7 @@
|
||||||
frame = UIEdgeInsetsInsetRect(frame, insets);
|
frame = UIEdgeInsetsInsetRect(frame, insets);
|
||||||
|
|
||||||
self.scrollView.frame = frame;
|
self.scrollView.frame = frame;
|
||||||
return [self updateLayoutIfNeeded:YES];
|
return [self updateLayoutIfNeeded];
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0.f;
|
return 0.f;
|
||||||
|
|
|
||||||
|
|
@ -394,7 +394,7 @@ static void * const kTLYShyNavBarManagerKVOContext = (void*)&kTLYShyNavBarManage
|
||||||
|
|
||||||
- (void)layoutViews
|
- (void)layoutViews
|
||||||
{
|
{
|
||||||
if (fabs([self.scrollViewController updateLayoutIfNeeded:YES]) > FLT_EPSILON)
|
if (fabs([self.scrollViewController updateLayoutIfNeeded]) > FLT_EPSILON)
|
||||||
{
|
{
|
||||||
[self.navBarController expand];
|
[self.navBarController expand];
|
||||||
[self.extensionViewContainer.superview bringSubviewToFront:self.extensionViewContainer];
|
[self.extensionViewContainer.superview bringSubviewToFront:self.extensionViewContainer];
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue