iPhone UIScrollView Continuous Circular Scrolling - iphone

I have found similar questions here but none of them are answered. So please help me..I have a UIScrollView with five UIImageView as contents. No paging is there for the scroll view. I need to display the images in a continuous manner and allow the user to scroll infinitely without any jerk in a circular manner. So when the user scrolls to the right, after the last image, the first image should come and the scrolling should continue in the natural way. Similarly if the user scrolls left, after the first image, the fifth image should appear. I used didEndDeceleration but it will apply a sudden break to the scrolling giving a distortion to the user experience. Also, surprisingly, it is not called at the end of the scroll every time. I am now trying to override the setContentOffset of the UIScrollView by subclassing it. The result was better than didEndDeceleration but the sudden break is still there. Please help me..
Thanks in advance.

Apple's Street Scroller demo from their UIScrollView presentation at WWDC 2011 should give you enough info to get this done. I also recommend watching the video. Has a lot of good stuff.

Related

iPhone: Best way to handle 400 UILabels in UIScrollview

I've been working on a crossword app for a while. The actual game runs in a UIScrollview, because the player should be able to scroll, zoom and pan.
To the UIScrollview i added a UITapGestureRecognizer that handles the touch-event, and calculates where the player touched. So far so good.
Afterwards I added about 400 UILabels to the UIScrollview. Each of them are "empty" until the player presses a button on the keyboard. My problem is that when i add these labels the whole UIScrollview become very slow and laggy in scrolling etc.
As the user guesses the right words green tiles will become visible. The tiles are loaded in as UIImageViews. This reduces the performance again.
I have looked at DTGridView, but I've got no luck with it.
Can you please help me out and try to guide me in the right direction?
i think you should implement the UIScrollview method drawRect you self instead of add 400 UILabel in it
you can set a NSArray contains 400 objects called "label";
when user pressed the button, you should calc the postion & test of the "label" &decide which "label" should display in the scrollview in current offset .
add 400 UILabels in one UIScrollview may cause the memory problem;
You need to use recycled label in your scrollview. That will improve the performance. To know how to reuse/recycle subviews in UIScrollView please check Apple WWDC videos on UIScrollView. WWDC 2010 Sample Code . Also check UIScrollView Class Refference UIScrollView Class Reference
You can get help from this link Creating Circular and Infinite UIScrollViews
I've been playing with this for the past while/days even. Using various related answers. But eventually I used instruments and a bit of commenting to see what was slow.
I remember someone saying layoutSubviews slows things when you addSubviews, so I took my "Local" code out of there. But nothing sped up.
So when using a breakpoint during my addSubview routine, I noticed the iOS system was actually in a superview's layout calls (navigationCtrlr) during viewDidLoad.
I introduced a 0.1 second delay before adding subviews and bam! I recommend dispatch_async to prevent crashes from race conditions, but that's another subject.
In short, it might be in LayoutSubviews even if you don't think you are there.

Vertical and horizontal scoll at a time in gridview with infinite scrolling IOS

How can one enable horizontal and vertical scrolling at same time in a grid view?
If I have a 4x4 grid of thumbnail images, I want to implement swiping in both directions, left/right and top/bottom. Currently I am done with left and right swipe, but if I select the second cell and swipe towards the top, the 2nd row should be scrolled like a Rubik's cube.
Please share if any one have any idea.
It's been quite a while since your question but as I've been struggling with the same thing I'm gonna answer it for future reference...
Sadly I could not find a good solution anywhere so after a lot of hours of experimenting I came up with this: https://github.com/AlvinNutbeij/DWGridController
It's still a work in progress but very usable for your purpose I'd say!
How have you currently implemented what you have? Your mention of 'cell' makes it sound like you are using a UITableView. You won't manage to make one of those scroll in both directions, you'll need to work with a UIScrollView.
I suggest you watch "Designing apps with Scroll Views" from WWDC 2010, then "Advanced Scrollview Techniques" from WWDC 2011. That'll teach you about how you implement tiling and infinite scrolling.
Essentially what you want to do is implement some kind of view recycling yourself, that works like the way UITableView recycles its cells. When things are scrolled off one side of the scroll view, you remove the views for the things that just scrolled off screen and put them in a queue. When things scroll onto the screen, you pull views out of the queue (or create new ones if the queue is empty) and lay those views out in the correct place.
To do the infinite scrolling, you fake it: when your scroll view gets near its edge, you reposition everything inside it, you move the scroll view's content offset to where you've repositioned the views, and then you continue from there: it's all done at once so the user never notices.
The videos will explain these techniques better than I can sum up here: watch those as your first point of call.

UIScrollView - how to get rid of delay before scrolling?

I'm using a UIScrollView to display a custom UIView. When the user drags a finger across the UIScrollView, there is a noticeable delay before the display begins updating. If the user keeps touching the screen, the UIScrollView becomes very responsive after a short time. Subsequent attempts to scroll result in the same initial delay, followed by high responsiveness. This delay seriously affects the usability of the view and I would like to get rid of it.
In a test project I have written to try to get to the bottom of this issue, I have only been able to partially replicate the behaviour. The first time that the user scrolls is exactly the same - however any subsequent attempts to scroll are responsive straight away.
I have tried both setting delaysContentTouches = NO and subclassing UIScrollView so that touchesShouldBegin returns NO as suggested in multiple places online, but neither has worked.
I'm using MonoTouch on iOS 4.3, but Objective-C answers are fine. I would post code to help illustrate the issue, but since I have been unable to narrow down the problem this would be well over 1000 lines. Hopefully this is enough info to get a solution.
Does anyone know what might be causing this delay, and how I can get rid of it?
Some general suggestions for improving scrolling performance.
Have your scrolling views rasterize offscreen:
myView.layer.shouldRasterize = YES;
Set that property for each sub-view on the scrollview - do not set it for the children of those sub-views or you just eat up memory that way.
If your scrolling views do not need compositing, make sure you turn that blending off:
myView.opaque = YES;
Test using the simulator by leveraging these two features that appear on the Debug menu of the iOS Simulator:
Color Off-screen Rendered
Color Blended Layers
If that doesn't address your problem, and you have implemented UIScrollViewDelegate, double-check to make sure you are not doing anything time consuming in those methods - for example, based on your description, you might be doing something in scrollViewDidScroll, scrollViewWillBeginDragging, or scrollViewWillBeginZooming and if you are, optimize that so it happens before scrolling even begins. Also, make sure you're not doing anything in touchesBegan.
I suspect what is happening is there is some kind of interaction enabled in the content of your scroll view.
The system does not know if the initial touch down is going to be a tap on one of the subviews or a drag on the scroll view, therefore is causing a delay while it waits to see if you are going to lift your finger.
What are the subviews of the UIScroll view?
As an experiment set all the subviews of the UIScrollView to have userInteractionEnabled = NO, this will not be what you want, but its just a test. Is should scroll fine after this, otherwise I am wrong.

UIImageView in UIScrollView

I have a series of UIImageViews in a UIScrollView. The user can zoom into each one, but after a bit of usage the images start disappearing, and then various images in the app disappear. I'm wondering if anybody has any any experience with this and has any idea why this could be happening?
Its a complete guess until you give us source, but chances are that you are doing something like not retaining your image views or are adding them to another view – effectively removing them from the first view they were in.

Special UIScrollView with multiple objects (3) on each page

What I want to accomplish is something like this:
Two different scrollViews, and each one scrolls horizontically. Each showing 3 images, and a half one (or 1/3th) piece of the next image in the datasource of the scrollview.
Does anyone know how to accomplish such a scrollview?
I also want to be able to tap an image to flip it and show some information and a button to the detail. (See lower scrollview).
Tapping it again would just show back the image, much like the coverflow ui inside itunes, but without the coverflow being 3D...
Any help is welcome :)
Thanks in advance,
Lewion
Scroll view doesn't have a datasource. What you are looking for is standard scrolling and nothing special.. So it is definitely doable... Check the scrolling and photo scroller sample codes from apple developer samples. For more implementations of scroll view check the scroll view suite sample code and read the scroll view programming guide.
The flip animation is also a standard animation for a view and is easily doable. For example, create a utility application for iphone. It has a flip side view. See how that animation is done.