UIScrollView, how to scroll frame by frame in iPhone app? - iphone

I would like to show a gallery using a horizontal ScrollView; i would like to show an item and, when the user swipes, animate to a certain position to avoid to see partial images but centering the next item to the screen and "dock" the item to (x,y) coordinates.
How can i do it?

I hope I understand this right. When the user swipes, you want to scroll to the next picture (using an animation). Also, the scrollview should then snap on the picture so that it doesn't display any other partial images.
If this is the case, then you can use scrollView.pagingEnabled = TRUE. You will have this snapping (docking) and swiping features implemented.
All you need to do is to arrange the pictures inside the scrollview so that it is only one picture per screen.
If you expect a lot of images, then you can improve this design by storing only the previous, current and next pictures. When the user scrolls from current -> next, then you will have something like this:
previousImage = currentImage;
currentImage = nextImage;
nextImage = //Load the next gallery image
If you need more help, feel free to ask.

Related

Scrolling whole Image from UICollectionView

I have a UICollectionView with UIImage and when i tap on the Cell it´s comes a whole UIImage. I want to Slider Right or Left on the whole Image then show the next UIImage from the UICollectionView like a Photo Gallery. How can i make that ? Thanks for Help.
UICollectionView and Whole UIImage
You could use a UIScrollView for that, large enough to carry 3 images, the current one, the previous one and the next one. The largest is in the middle. The scrollview scrolls horizontally. Then you react on scrolling (and gestures) and when the user scrolls to right or left then you scroll your scrollview to the middle again and realign the 3 images by discarding one and adding a new one dependig on the direction the user scrolled.

Zoom An Entire View Controller

I have an app im working on. The main view controller has a keypad ( like on a safe door). I want the user to tap on the numbers pad and i want the whole view to zoom in. This is not a UIImageView. I know how to zoom an image/imageView. I want to have a super small set of numbers/number pad, and a super small textfield, then when it zooms in, those two UI elements will be big. I would like to have this done via button press!
Thanks in advance. I have no code to provide! Sorry, And Thanks :D
One possibility is to just make an imageview, zoom this to your desired size, then hide it and "replace it" by the real number pad. To do that just have the number pad hidden at the beginning and visible, once the image view reaches its final size and disappears (just hide it then)
To the user it all looks as if the "number pad" will zoom - which is actually your image of the number pad.
Also to have only one View to hide/unhide just put your all your keys of the number pad and whatever else on one container view.
To get the image to be zoomed, just make a screenshot and cut out your zoomable image area with some kind of Photoshop tool.
By the way, I would expect your idea of a zooming number pad will surely be a nice animation in your app!

Animate UIViews like iPad photos application

I want to make an application like photos of iPad in which it displays photos in grid manner and after clicking over custom-view it animated from its current position.
I just want to know how to animate view from its current position like if i click over the custom-view which is first line then it will show that custom-view animating from top position and if i click over the custom-view which is in bottom line then it will show and animate custom-view from bottom position and same for middle line also. Any help and suggestion will be appreciated.
If you don't specify the from value then the current value is the default. If you still want to specify the default value then the current frame of the image would probably do.
Depending on what happens next in your application and if the images resize or not you may need to animate a transform as well. Otherwise just animating the frame from its current value to [[UIScreen mainScreen] applicationFrame]; will be a good starting point.
Also, depending on where your image is in the view hierarchy you may need to move it to appear on top of tab bars and navigation bars if you truly want the image to appear full-screen when tapped.

iPhone - scrolling a UISCrollview to keep objects moving

I have a UISCrollview. Inside this scroller I have a picture and over the picture I have some objects (as subviews of the picture), like layers in a Photoshop composition. So, if I zoom the picture, the objects will zoom. If I scroll the picture, the objects scroll.
Now consider this: I have the picture zoomed in. The picture is now larger than the iPad screen. I am seeing the top half of the picture. I touch an object that is over the picture and start dragging it to the bottom of the screen. My intent is to drop the dragged object at the bottom of the picture, but as the picture is zoomed in, I have to drag the element to bottom of the screen, release it, scroll the picture up and then continue dragging the object.
What I want is this: I start dragging and when I arrive at the boundary of the screen, the scroller starts scrolling automatically showing parts of the image that were down or up.
What do I need is to know the rect that is visible, a kind of inverse of scrollRectToVisible...
Considering that the picture can be zoomed at any level, how do I know if the element I am dragging is near the border. BTW, how do I know what part of the scroller is being shown, even if it is zoomed?
thanks.
The visible rectangle has a size of scrollView.bounds.size and an origin of scrollView.contentOffset, in the coordinate space of the scrollview. Depending on what exactly you are doing, you may need to use convertRect:fromView: or convertRect:toView: to convert it into the coordinate space of the zoomed view.

2 UIScrollView detect current page and loading correct ppage

First part of the question: Detecting current images being displayed in scrollview A and B
i want to place two UIScrollViews in my main view. Very simply done. So ive placed UIScrollView A above UIScrollView B.
so it looks like this:
Graphical representation
________
| A | ScrollViewA is above ScrollViewB
|______|
| B | ScrollViewB is below ScrollViewA
|______|
There will be images which the user can flick through left and right on both ScrollViews.
They both show different set of images.
First i want to know how to detect which image the both scrollviews are on. for both A and B.
so i should be able to detect which images are being displayed on scrollviewA and scrollview B
eg: UIScrollView A is on image 12 and UIScrollView B is on image 67.
Second part of the question: Loading images on both scroll view as user scrolls from left and right
Because there will be many images in ScrollViewA that the user can scroll from left to and right; and many images in ScrollViewB that the user can also scroll from left to right; obviously i dont want to load them all into the scroll view. Whats the best way i can load them in a scrollview?
an idea is if a user is on image 5, then the user flicks to the left, then the next image will be 6 so only load that image. and so on.
Can everyone help me on how to implement such a thing. Thank you.
All your ideas and help will be appreciated.
On loading images, you can do this:
Load current image
Buffer load next and previous images and position them outside the bounds of the visible view
When user flicks left, move right image into view, unload the left image and buffer a new right image. Do the same thing for the right one.
This way you will only have 3 loaded at a time for a scrollview.
On keeping track of which image is loaded, you have to keep track of that yourself.