How to implement an auto scroll view like notification center's stock ticker? - iphone

I want to implement a scroll view which looks like the stock ticker. It can respond slide or tap gesture.
How can I implement this? Please advise me. Thank you!

Use a NSTimer to reposition the contentOffset of your Scrollview.
Use the UIScrollViewDelegate to stop your animation while the user is dragging the scrollview.

Conceptually I'd setup an container UIScrollView with the contents of the scrolling area as subviews. To simulate a circular scroll I'd keep an array of the subviews. I'd add a view just off screen at the starting edge, and take away a view just off screen at ending edge.
UIScrollViewDelegate methods will be called when a person starts or stops dragging the view, which you can use to start and stop the animated scrolling. Other methods in this protocol can be used to reset the contents of the scrollview when the edge is reached, so more views can be added as needed.
I'd probably use a CADisplayLink to manually manage the animations. The method given to the CADisplayLink would update the scroll and manage adding and subtracting views to the edges. It would also stop scrolling based on a flag set by the UIScrollViewDelegate methods when the person is dragging the scroll.

Unless you jailbreak, you can't put custom views in Notification Centre.

Related

Swift ScrollView what gesture is called when scrolling is ended if the contentSize is equal to the frameSize?

I can't figure out a solution. I have a UIScrollView, and on each scroll towards right, I will increase the contentSize of the scrollView and add a View at that place. The problem is I have managed to save the last content offset by delegation when scrollview start dragging but I don't understand which delegate method to use for measuring where the gesture stopped. If I use scrollViewDidEndDecelerating, will be called immediately after the scrollViewWillBeginDragging because the content is settled to the same size of the frame.
Does anybody have any solution on it?

Preventing ScrollView from scrolling in certain area?

I hope you can help me...
I have a scrollview (UIScrollview) that contains a contentView (UiView).
Inside the contentview I have a Horizontal slider. My problem is that if the user swipes just next to the slider, trying to hit the slider, the scrollview scrolls. I would like to enlarge the area of the slider if possible, or just disable scrolling for a certain part of the scroll view.
Is this possible, and if yes, how?
Thanks...
You need to look at the following properties for customizing the look of a scroll view:
indicatorStyle
scrollIndicatorInsets
Or if this isn't to your taste: You could subclass UIScrollView and when the custom slider receives touches, read them in transform them and call setContentOffset on the UIScrollView. In my opinion that seems like a big task for very little reward and I'd just stick with the default behaviour/look.

Can I make a UIScrollView only scroll when i interact only with specific places in the view? UIScrollView iPad

I have a UIScrollView wich contains 2 views the first at offset 0 and the other at offset 800.
I want the user to be able to scroll down but not always, because in the upper view i have another controls tha receive touch input and dragging and sometimes when you are dragging if your touch is just a little bit out of the control the scrollview scrolls and that's very annoying. So i want that the scrollview only scroll in certain zones.
What you basically need is to subclass the UIView that should intercept touches outside it's frame and override it's hit test method.

Second UIScrollView responding when using a UIScrollView

This is more of a check as I believe this is right but its a lot of work if I'm wrong.
I want to basically achieve fixed positioning with a scrollView. I want to have a list along the top that is always visible, scrolls horizontal only and then a scrollview beneath that to move around the information which scrolls both vertically and horizontally.
I figure I need to subclass UIScrollView and overwrite touchesBegan, touchesMoved and touchesEnded to send the touch to both UIScrollViews.
Is this right or off track?
Cheers
Overriding the touch events on a scroll view is probably not what you want to do. Instead you can simply use a single scroll view, and then in the parent view's -layoutSubviews or in the scroll view's delegate methods you can move the list so it's always at the same vertical position (use the scroll view's contentOffset property to determine where that should be). Both the delegate method and -layoutSubviews is called before the drawing actually occurs after the scroll view scrolls, so by always repositioning your view where you want it to be, it will appear to remain fixed to the user.

Scroll view touch detection

I have a problem in the touchesMoved handler with a view that is added onto a UIScrollView. I add a number of labels to the scroll view. Each of these labels contain some text and, on swiping my finger on the labels, I have to play a specific file for that text.
If I just add the view onto the window directly, I get all of the touch events in touchesMoved without any problem. When I add my view onto the UIScrollView and then add this to the window, there is some lag in the touchesMoved handler. I am not getting continuous touch points in touchesMoved as with the normal view. As a result, while swiping the finger from the view, it happens that some labels are missed.
Is the problem due to scroll view? The same code runs perfectly in normal conditions (without a scroll view).
Does anyone have any solution to this?
UIScrollView sets a timer on touchDown to be able to know if it should handle scrolling or if it should pass the events on to subviews.
There is a property on UIScrollView for controlling this behaviour:
#property(nonatomic) BOOL delaysContentTouches