UIScrollView with Paging - iphone

I am struggling with a problem related to uiscrollview.I need to load 3 images simultaneously into a scrollview like the attached image.If there is only one image the then that image should be shown centrally .If there are two images then first image should be shown centrally and half of the next image should be shown right to it.If there are three images then half of the first then second image centrally and finally half of third image .If the user scrolls it then the third image should come center,second should go first(show only half) and also the fourth image if any should load next.I am attaching my requirement here ,Looking for a solution thanks in advance...

You may find a better solution using core animation than using a scrollview. For example each of these images can be a CALayer or even a UIImageView that you can place and move around in a parent view or layer.

Related

Hiding a part of an image in iPhone-Game

I am working on a small game, in which the user can drag rows and columns of images to solve a puzzle.
The puzzle does not use the whole screen, the "puzzle area" is in a rectangle area from 0,160 to 320,480.
Now, if the user drags a column of the images up, the top image in that column would be displayed "out of" that puzzle area. How could I only have that portion of the image shown, that remains within the puzzle area. Like not showing the whole 50x50 Pixel of the image, but only the lower 40x50 Pixel etc.?
You just need to set the frames on your views properly. If your puzzle views frame ends at the (0,160) point on top, any subviews you've added to it; such as the puzzle pieces will be hidden when they move out of the frame.
Hopefully I'm not oversimplifying the problem, but one of the easier ways I can think of working this scenario is by maintaining a proper view structure while moving the puzzle pieces.
i.e. as long as the view on the top half of the screen is higher up on the view hierarchy than the puzzle pieces (you could ensure this by properly maintaining the subviews), the puzzle pieces will be hidden under the top view if they move beneath it.
Is this what you need?
Cheers.
I am just tryin to give u some ideas.. Hope u can implement with that...
First use touchesBegan and touchesMoved methods to detect how much pixels the image has been dragged. Simultaneously u can also move the frame of the image to a new coordinate , hiding a portion of the image....tat is out of puzzle area.....
Hope this helps....
myImageView.frame=CGRectMake(0,0,50,50);
Let the above one be the actual frame. Now u have received the amt of pixels thru which the user has moved the image from touches method. Let it be some y1. To hide a part of the imageview reframe the imageview like this ,
myImageView.frame=CGRectMake(0,-y1,50,50);
negative y1 since u want to move out of the screen..
Hope this helps.

UI Button with Image Smaller than Touchable Area

I've not much response so am adding some more info.
My buttons are not rectangular, nor organised in a grid so I need a way of creating what looks like a button (and shows that it has been pressed visually, as per a standard UIButton) but where the touchable area is different to the image area.
I am using a transparent PNG and that element works fine. I've added the buttons in Interface Builder and am wondering if that is the problem.
However, if I change imageEdgeInsets, it distorts the image display, which is obviously not what I want.
Bizarrely, if I increase the dimemsions of the button, it doesn't change the image, but if I decrease them it does.
I have tried different combinations of mode (scale to fill etc), but to no avail.
I am aware that there is an image and background image property, but in IB there is only one.
Essentially, I don't understand how the geometry works and the Apple documentation doesn't seem to help.
Surely, I can't be the only person to try to do this. Any help would be warmly welcomed.
Many thanks,
Chris.
Try setting the buttons setting to Aspect Fit. This will fill the button with your image so a smaller image than the button size would leave the space around the image.
Also set the button type to custom.
In the end, I stumbled across Ole Begemann's Non-rectangular buttons class. It just does what I need - to be able to create buttons where the touchable area follows the visible element of a non rectangular image.
#Helium3 - thanks - that allowed me to use a larger touch area, bit not a smaller one.

View Behind View rolldown effect on iOS (Like folders on home screen)

What would be the best way to accomplish the home screen folder roll-open effect with views in Objective C?
I tried something similar to what MaxFish has described. You can check it here iOS Open Folder Animation Sample Code
If you take a look at the images inside the Springboard.app in your iPhone in "/System/Library/CoreServices" you can have an idea of how the animation works.
A simple version of the effect can be done this way:
Take a screenshot of the screen you want to "cut" and save it in an image
Create two imageviews each of which has a part of the screenshot (e.g. the first has the first upper part of the image as background, the second the rest), you could alternative use the same background image for both views, you have only to play with content alignments.
Place the two views on the original screen in the exact position to make them seem like one entire image perfectly aligned with the original screen.
Create a view (folder content) with its own background and whatever you want to put inside, place it at the same Y of the bottom imageview but beneath it.
Make the bottom image view scroll down for the entire size of the content view, you will see the folder content appear.
iOS version put on the sliding images some nice borders and applies fade effect which make the overall animation really cool. You can sure try and make it nice looking.
Hope this helps

image Gallery in iPhone

I need to Create an Image Gallery that may be use concept of scrolling and paging together.
When I click on a button, it will open a new view in landscape mode. This view is for my Image Gallery..
It shows 5 Images:
Centered Large Image With its description on Bottom.
Next Coming image on left side, This image is slightly tilled at some angle, Without any description at bottom.
next to next coming image on left to 2nd image.
previous image on right side, This image is slightly tilled at some angle, Without any description at bottom.
Previous to Previous image on right of 4th image
Moreover, all images should be scrollable, like when I scroll 2nd image, it will move to Center and show its description and image which is already centered move to previous image.
Sorry for my confused English, here's an example of what I am trying to obtain.
I tried for basic code of paging and scrolling but unluckily nothing helpful.
Could you give me some pointers?
Check out flowcover (see this question: Open source CoverFlow library for iPhone), which should get you started.
I think someone reported flowcover doesn't work on iOS 4.0, I haven't tried yet, ofcourse.
But, you can also take a look to this OpenFlow project, It will be help you I guess. Many people has builts their app on this library.

What would be the best way of providing small image selection in an iPhone App?

I have a bunch of small png images with about 45 x 45 pixels of size. not really big ones. there are about 40 of them right now.
I want that the user can select one of them as his avatar image. For this, I created an brand new view with an controller class. Now the problem is: How to display all those images to the user? There's no "big view". When the user touches one of them, it's going to be selected and the view switches back to the main view, where he's going to see his selected image. When he touches it, the image selection view will appear again.
So I thought about an table view, but it feels not right. The images have no title to be displayed, so it would be a big waste of screen space.
Any ideas? Should I programmatically generate a grid of UIImageView objects?
A grid is correct. Think iPhone Photos application. No need to make a completely new widget though, add multiple image views to table rows, segmenting them.
A grid seems like a good solution as it mirrors the wallpaper ui in settings so the user knows what to expect.
Another option in this case would be to use a UIPickerView. It takes up less screen space, and can be shown on the main screen (just pop up from the bottom, let them pick one, then disappear).