uiscrollview interview questions
Top uiscrollview frequently asked interview questions
While a UIScrollView
(or a derived class thereof) is scrolling, it seems like all the NSTimers
that are running get paused until the scroll is finished.
Is there a way to get around this? Threads? A priority setting? Anything?
Source: (StackOverflow)
In my scroll view, I want to get the current page that's being displayed (maybe page isn't the correct term). I can't find any variable that holds this. But I think it must be held somewhere, since the indicator is able to show which sub-view of the scroll view is currently being displayed.
Is this hidden from us completely or is there a way for me to access it?
Source: (StackOverflow)
How can I detect touch points in my UIScrollView
? The touches delegate methods are not working.
Source: (StackOverflow)
How can I go about finding out the rect (CGRect) of the content of a displayed view that is actually visible on screen.
myScrollView.bounds
The code above works when there's no zooming, but as soon as you allow zooming, it breaks at zoom scales other than 1.
To clarify, I want a CGRect that contains the visible area of the scroll view's content, relative to the content. (ie. if it's a zoom scale 2, the rect's size will be half of the scroll view's size, if it's at zoom scale 0.5, it'll be double.)
Source: (StackOverflow)
I've got an use case where those indicators disturb the user interaction. Can I subclass and overide an method or something similar to remove the scoll indicators from the scroll view?
Source: (StackOverflow)
When a UITextField, embedded in a UIScrollView becomes first responder, by lets say the user typing in some character, the UIScrollView scrolls to that Field automatically, is there any way to disable that?
Duplicate rdar://16538222 over https://bugreport.apple.com
Source: (StackOverflow)
I have a UIScrollView (actually a UICollectionView, but that probably doesn't matter). When it appears in IOS 7, the navigation controller sets its contentInset and contentOffset to values I don't want. It appears to be trying to adjust for the status bar and the navigation bar. I'd greatly prefer it left them alone. I've fixed this by overriding the getter and setter methods for contentInset and contentOffset, with a flag to tell the object whether or not it should accept a set. But is there a better way?
Source: (StackOverflow)
I have a UIView
like iPhone's Springboard. I have created it using a UIScrollView
and UIButtons
. I want to disable horizontal scrolling on said scrollview. I want only vertical scrolling. How do i accomplish this?
Source: (StackOverflow)
Is there a way to make a UIScrollView
auto-adjust to the height (or width) of the content it's scrolling?
Something like:
[scrollView setContentSize:(CGSizeMake(320, content.height))];
Source: (StackOverflow)
How can I force a UIScrollView
in which paging and scrolling are on to only move vertically or horizontally at a given moment?
My understanding is that the directionalLockEnabled
property should achieve this, but a diagonal swipe still causes the view to scroll diagonally instead of restricting motion to a single axis.
Edit: to be clearer, I'd like to allow the user to scroll horizontally OR vertically, but not both simultaneously.
Source: (StackOverflow)
I am currently trying to implement the UITableView reordering behavior using UICollectionView.
Let's call a UItableView TV and a UICollectionView CV (to clarify the following explanation)
I am basically trying to reproduce the drag&drop of the TV, but I am not using the edit mode, the cell is ready to be moved as soon as the long press gesture is triggered. It works prefectly, I am using the move method of the CV, everything is fine.
I update the contentOffset property of the CV to handle the scroll when the user is dragging a cell. When a user goes to a particular rect at the top and the bottom, I update the contentOffset and the CV scroll. The problem is when the user stop moving it's finger, the gesture doesn't send any update which makes the scroll stop and start again as soon as the user moves his finger.
This behavior is definitely not natural, I would prefer continu to scroll until the user release the CV as it is the case in the TV. The TV drag&drop experience is awesome and I really want to reproduce the same feeling. Does anyone know how they manage the scroll in TV during reordering ?
- I tried using a timer to trigger a scroll action repeatedly as long as the gesture position is in the right spot, the scroll was awful and not very productive (very slow and jumpy).
- I also tried using GCD to listen the gesture position in another thread but the result is even worst.
I ran out of idea about that, so if someone has the answer I would marry him!
Here is the implementation of the longPress method:
- (void)handleLongPress:(UILongPressGestureRecognizer *)sender
{
ReorganizableCVCLayout *layout = (ReorganizableCVCLayout *)self.collectionView.collectionViewLayout;
CGPoint gesturePosition = [sender locationInView:self.collectionView];
NSIndexPath *selectedIndexPath = [self.collectionView indexPathForItemAtPoint:gesturePosition];
if (sender.state == UIGestureRecognizerStateBegan)
{
layout.selectedItem = selectedIndexPath;
layout.gesturePoint = gesturePosition; // Setting gesturePoint invalidate layout
}
else if (sender.state == UIGestureRecognizerStateChanged)
{
layout.gesturePoint = gesturePosition; // Setting gesturePoint invalidate layout
[self swapCellAtPoint:gesturePosition];
[self manageScrollWithReferencePoint:gesturePosition];
}
else
{
[self.collectionView performBatchUpdates:^
{
layout.selectedItem = nil;
layout.gesturePoint = CGPointZero; // Setting gesturePoint invalidate layout
} completion:^(BOOL completion){[self.collectionView reloadData];}];
}
}
To make the CV scroll, I am using that method:
- (void)manageScrollWithReferencePoint:(CGPoint)gesturePoint
{
ReorganizableCVCLayout *layout = (ReorganizableCVCLayout *)self.collectionView.collectionViewLayout;
CGFloat topScrollLimit = self.collectionView.contentOffset.y+layout.itemSize.height/2+SCROLL_BORDER;
CGFloat bottomScrollLimit = self.collectionView.contentOffset.y+self.collectionView.frame.size.height-layout.itemSize.height/2-SCROLL_BORDER;
CGPoint contentOffset = self.collectionView.contentOffset;
if (gesturePoint.y < topScrollLimit && gesturePoint.y - layout.itemSize.height/2 - SCROLL_BORDER > 0)
contentOffset.y -= SCROLL_STEP;
else if (gesturePoint.y > bottomScrollLimit &&
gesturePoint.y + layout.itemSize.height/2 + SCROLL_BORDER < self.collectionView.contentSize.height)
contentOffset.y += SCROLL_STEP;
[self.collectionView setContentOffset:contentOffset];
}
Source: (StackOverflow)
I have a UIScrollView
which has several views. When a user flicks their finger, the view scrolls to the right or left depending on the direction of the finger flick. Basically my code works in a way similar to the iPhone photo app. Now, is there a way that I can programmatically do the same thing so that I end up with a slideshow that runs on its own with a click of a button and a configurable pause between each scroll?
How do you really do slideshows with UIScrollView
?
Source: (StackOverflow)
Can someone explain to me what the contentInset property in a UIScrollView
instance is used for? And maybe provide an example?
Source: (StackOverflow)
How can I make a UIScrollView
scroll to the bottom within my code? Or in a more generic way, to any point of a subview?
Source: (StackOverflow)