Closed Shayanzadeh closed 9 years ago
I am certain that this is not the default UIKit behavior on iOS 8. Set an Xcode symbolic breakpoint on [UIScrollView setContentOffset:]
and read the call stacks until you find your culprit.
On Feb 22, 2015, at 12:26 AM, Shayan Yousefizadeh notifications@github.com wrote:
Hi,
First of all thank you for all the amazing work on this project.
The issue I have is very minuscule. In iOS 8 while using a UITableView, I present the JTSImageViewController and upon dismissal the table view scrolls (not animated) to the top, that is to say the contentOffset is lost.
I read through most of the code in JTSImageViewController.m and it is not at fault. Apparently it's the default behaviour to reset the contentOffset after returning from a modal view controller. I have tried automaticallyAdjustsScrollViewInsets = NO and using a UITableView inside a UIViewController instead of a UITableViewController but no luck. I've also tried setting the contentOffset back after the dismissal but it flashes.
It seems setting the modal presentation style of JTSImageViewController to UIModalPresentationOverFullScreen fixes the issue (since it doesn't remove the hierarchy below it and retains the scroll position I think). As this enum is new to iOS 8 I am going to assume that it's an iOS 8 only issue (since if it wasn't there would be more issues about it).
Any thoughts? Has anyone else experienced this? If so should I make a pull request for this simple change?
if ([[[UIDevice currentDevice] systemVersion] compare:@"8.0" options:NSNumericSearch] != NSOrderedAscending) { self.modalPresentationStyle = UIModalPresentationOverFullScreen; } — Reply to this email directly or view it on GitHub.
Thanks for the response.
I just tried that and looking at the call stack I don't see anything that could be causing it (that is in our control at least). Looks like most of it is just private internal methods that get called that trigger it. I Googled _adjustContentOffsetIfNecessary
and this tweet by Peter Steinberger suggests to make sure the main view isn't a scrollview and the first subview is a dummy view, as well as setting automaticallyAdjustsScrollViewInsets = NO
, but I have tried both of those and it doesn't work.
Unfortunately I have to finish this app in the next 3 days so I can't spend anymore time investigating, and my solution works in my case so I will just move on.
(lldb) bt
* thread #1: tid = 0x413cb, 0x00000001867ecd00 UIKit`-[UIScrollView setContentOffset:], queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
* frame #0: 0x00000001867ecd00 UIKit`-[UIScrollView setContentOffset:]
frame #1: 0x00000001868a2dd4 UIKit`-[UITableView setContentOffset:] + 300
frame #2: 0x0000000186aa7e40 UIKit`-[UIScrollView(UIScrollViewInternal) _adjustContentOffsetIfNecessary] + 864
frame #3: 0x00000001867e500c UIKit`-[UIScrollView setContentSize:] + 344
frame #4: 0x00000001868aa748 UIKit`-[UITableView _updateContentSize] + 540
frame #5: 0x00000001868b05f4 UIKit`-[UITableView didMoveToWindow] + 88
frame #6: 0x00000001867cd5f8 UIKit`-[UIView(Internal) _didMoveFromWindow:toWindow:] + 1464
frame #7: 0x00000001867eea34 UIKit`-[UIScrollView _didMoveFromWindow:toWindow:] + 68
frame #8: 0x00000001867cd310 UIKit`-[UIView(Internal) _didMoveFromWindow:toWindow:] + 720
frame #9: 0x00000001867cd310 UIKit`-[UIView(Internal) _didMoveFromWindow:toWindow:] + 720
frame #10: 0x00000001867cd310 UIKit`-[UIView(Internal) _didMoveFromWindow:toWindow:] + 720
frame #11: 0x00000001867cd310 UIKit`-[UIView(Internal) _didMoveFromWindow:toWindow:] + 720
frame #12: 0x00000001867cd310 UIKit`-[UIView(Internal) _didMoveFromWindow:toWindow:] + 720
frame #13: 0x00000001867cd310 UIKit`-[UIView(Internal) _didMoveFromWindow:toWindow:] + 720
frame #14: 0x00000001867cc9e0 UIKit`__45-[UIView(Hierarchy) _postMovedFromSuperview:]_block_invoke + 144
frame #15: 0x00000001867cc8c0 UIKit`-[UIView(Hierarchy) _postMovedFromSuperview:] + 484
frame #16: 0x00000001867d83a0 UIKit`-[UIView(Internal) _addSubview:positioned:relativeTo:] + 1764
frame #17: 0x0000000186805784 UIKit`+[UIView(UIViewAnimationWithBlocks) _setupAnimationWithDuration:delay:view:options:factory:animations:start:animationStateGenerator:completion:] + 508
frame #18: 0x000000018681d3d4 UIKit`+[UIView(UIViewAnimationWithBlocks) animateWithDuration:delay:options:animations:completion:] + 68
frame #19: 0x00000001868c3744 UIKit`-[UIViewControllerBuiltinTransitionViewAnimator animateTransition:] + 1140
frame #20: 0x0000000186ace738 UIKit`__56-[UIPresentationController runTransitionForCurrentState]_block_invoke + 1836
frame #21: 0x0000000186853564 UIKit`_applyBlockToCFArrayCopiedToStack + 356
frame #22: 0x00000001867c4e78 UIKit`_afterCACommitHandler + 532
frame #23: 0x0000000181fdaa50 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 32
frame #24: 0x0000000181fd79dc CoreFoundation`__CFRunLoopDoObservers + 360
frame #25: 0x0000000181fd7dbc CoreFoundation`__CFRunLoopRun + 836
frame #26: 0x0000000181f050a4 CoreFoundation`CFRunLoopRunSpecific + 396
frame #27: 0x000000018b09f5a4 GraphicsServices`GSEventRunModal + 168
frame #28: 0x0000000186836aa4 UIKit`UIApplicationMain + 1488
frame #29: 0x00000001000e3600 Jailbreak`main(argc=1, argv=0x000000016fd37a60) + 116 at main.m:14
frame #30: 0x0000000192ddaa08 libdyld.dylib`start + 4
I totally forgot to mention that I was using iOS 8 dynamic cells with self.tableView.rowHeight = UITableViewAutomaticDimension;
and that is completely the problem. Jerky scrolling and contentOffset issues due to it falling back on estimatedRowHeight
and it being a poor estimate of the actual cell heights hence scrolling up. It's already given me days of grief with other things like pull to refresh and pagination and pushing a new view controller. There's even bug reports in the developer forums. I'm going to close this as there's nothing we can do to fix it 😄
Hi,
First of all thank you for all the amazing work on this project.
The issue I have is very minuscule. In iOS 8 while using a UITableView, I present the JTSImageViewController and upon dismissal the table view scrolls (not animated) to the top, that is to say the contentOffset is lost.
I read through most of the code in JTSImageViewController.m and it is not at fault. Apparently it's the default behaviour to reset the contentOffset after returning from a modal view controller. I have tried
automaticallyAdjustsScrollViewInsets = NO
and using a UITableView inside a UIViewController instead of a UITableViewController but no luck. I've also tried setting the contentOffset back after the dismissal but it flashes.It seems setting the modal presentation style of JTSImageViewController to UIModalPresentationOverFullScreen fixes the issue (since it doesn't remove the hierarchy below it and retains the scroll position I think). As this enum is new to iOS 8 I am going to assume that it's an iOS 8 only issue (since if it wasn't there would be more issues about it).
Any thoughts? Has anyone else experienced this? If so should I make a pull request for this simple change?