I am using the code below to set the content offset of the uitableview after the retrieval of more data from a server.
[tablefollow setContentOffset:CGPointMake(0, tablefollow.contentSize.height- self.tablefollow.bounds.size.height-5+ (numLines*(25/numLines))) animated:NO];
For some reason when i scroll down fast with my finger i notice that the vertical scroll bar reaches the end and disappears but then reappears a few rows up just for a second and then disappears again! This is happening when i am scrolling with my finger fast to the bottom of the uitableview. This does not occur when i slowly scroll to the bottom of the uitableview. Anyone got this issue before?
Any help appreciated.
The issue was that the code i mentioned was called even when the user was scrolling the uitableview. It has nothing to do with the speed of the scroll. I just added a value in the scrollviewdidbegindragging and set it to TRUE and then when the scrollviewdidenddragging occurs i set it to FALSE. I have put this code in to my function
If (!scrollingvalue)
{
//execute code
}
When the value is FALSE (which means that the uitableview is not dragged by the user) then the code is executed else it is not executed. Hope it helps someone.
Related
I have an NSCollectionView with a vertical NSCollectionViewFlowLayout. I display rectangular icons in it.
I also have a slider in the UI, and when that changes, I adjust the minItemSize, which I then use in collectionView:itemForRepresentedObjectAtIndexPath: to create an equally sized NSImageView to the returned NSCollectionViewItem's imageView. Then I reload the view by invoking reloadData.
After that, the view shows the icons in the new size as intended.
The problem is, provided I have more data to show than fits into the current scoll view, that when the General System Preferences are set to Show scroll bars: When scrolling, the scrollbar disappears after reloading the collection view, and trying to scroll with the trackpad leads to a bounce that's telling me that the scroll view thinks that the content is just what's visible, nothing more to scroll.
But as soon as I resize the window, which also resizes the collection view inside, the scrollbars come back.
Curiously, if the System Prefs are set to Show scroll bars: Always, then the issue does not appear and the scrolling always works, and the scrollbars always remain visible.
I've tried a lot of things to trigger the re-calculation of the scroll view, such as invalidating the layout of the collection view's layout, the scroll view itself, its content view, and also tried to set their needsLayout to true. Nothing makes this work.
Update: The potential duplicate (NSCollectionView does not scroll items past initial visible rect), neither the collectionView.setFrameSize: nor the window.setFrame: suggestions work for my case (I tried adding these line before and after reloadData).
Even if I force a resize of the window like this, it doesn't bring the scrollbars back, only a manual dragging of the window edges does:
[self.collectionView.window setFrame:NSInsetRect(self.view.window.frame, 1, 1) display:YES];
Also note that in my case, initially the scrolling works, just not after resizing and reloading.
Another finding: When I call selectItemsAtIndexPaths:scrollPosition: after reloadData, then the scrollbar comes back. But only if I pass a non-empty NSSet for the paths. And since I may not have selected any items, this isn't a permanent solution.
If no other ideas come up, I'll try to make a demo project.
I've solved it:
I had to delay the call to reloadData, e.g. by calling it from within the block code of dispatch_async(dispatch_get_main_queue(), ^{ ... });
Before the fix, I did call reloadData right from the setSliderValue: handler, which is bound to the slider's value. It appears that this didn't go well together.
My problem: Find a way, such that when a button is pressed a new colleciton view cell is inserted by an animation of it sliding in from the right side of the screen.
As of right now, I have a button in my view, when it is clicked, adds a new object to my model, then calls reloadData and the new cells just appears on the screen. All I am struggling with is the animation. Any help would be very much appreciated.
Thanks
If you want the cells to animate, you could set a property shouldAnimate = YES.
Then in your collectionView:cellForItemAtIndexPath: check that property and apply the animation if needed (or remove it).
After setting the property, reload only the visibleCells: [collectionView reloadItemsAtIndexPaths:collectionView.indexPathsForVisibleItems].
Now, since the animation is provided when a cell is requested through the Datasource-Protocol, you also get the animation when you scroll.
I'v encountered strange bug, and have no idea why this happens.
I have UIScrollView, in it I have 12 views. Most of them contain UISwitch button and a label. Size of views are dynamic (depending on the lenght of label.text). Everything works and shows, except two views on the bottom. They do get shown, initialize as expected. Yet UISwitches in them do not work, clicking or touching them does not do anything. Both of them are no exception to others (all of them are copy paste). I have double checked IBOutlets, they are fine. I have suspicion something is wrong with scrollView. Maybe beyond some point it doesn't recieve inputs anymore? Eventhough I can scroll up and down and everything is shown just as expected.
Any ideas what to check ?
I have switched these two views with first ones. And more bottom views get unresponsive, like there is a line, beyond which ui is not responsive. Ideas?
You say the switch is in a view (one of 12) and that view is on the scroll view,
maybe the UISwitch is out of the view bounds? Try to set that views .clipsToBounds = YES;, can you still see the switch? If no, it means the switch is out of bounds therefor you gat no touch events. Make that view larger to fix that.
Check correctly. if the UISwitch and UIscrollview user interaction are enabled.
Check whether the UISwitch is added within the UIscrollview's frame.
I have an app in which a UIScrollView of the dimensions 1056x96 on top of a screen which is 480x320 (it is in landscape.) It contains 9 UIBUttons. It definitely is able to scroll, as when I set 'bounces horizontally' to true I can clearly see it bouncing back as soon as I attempt to scroll. It simply will not scroll beyond the bounds of the screen, and I have set its contentSize to 1056x960. Does anybody have a helpful suggestion as to why this is happening? Thanks in advance!
It appears that the contentSize property must be larger than the size of the UIScrollView its self. Once I made the size of that larger, it seemed to work fine.
Also, make sure your viewForZoomingInScrollView is set to the subview rather than the scroll view itself. For example:
- (UIView*)viewForZoomingInScrollView:(UIScrollView *)scrollView{
return self.menuView;
Do you have 'userInteractionEnabled' flag set to true?. Is the scrollView embedded into another view?. If so... please, check the 'userInteractionEnabled' flag as well.
Besides that, please, check if the flag 'scrollEnabled' is enabled both in your nib and in your code.
I have a UITextView that works well, till it's content is larger than it's own frame.
In that case it's scrolled down, but for some reason I cant re-scroll it back to the beginning, but only a few lines up.
How do I control the size of the content and the range of scrolling?
thanks
stupid problem, but I'll answer anyway:
I had a scrollViewDidScroll method in order to control a UITableView scrolling.
This method was called also when my textView was scrolled - and actually made some troubles.
so I just checked the sender in the first line:
if (sender==textView) return;
thanks for the help..