UIImage in UIImageView in UIScrollView? - iphone

What I want to do is displaying pages of a brochure at the iPad Display and allow the user to flip through the pages (left to right & right to left). The user should also be able to zoom in to articles at the pages.
I tried it with laying an UIImage into a UIImageView and then this UIImageView to a ScrollView. This works only if I have one Page. The second page is not displayed.
What would be the best way to do this ?

Set your scrollview pagingEnabled property to true, then set the contentSize to a size thats the sum of widths of all the imageviews. You then add each UIImageView to the UIScrollView making sure to position them next to each other.
Here is a tutorial talking about this: http://kwigbo.com/post/758575763/uiscrollview-image-gallery-tutorial
I'm not sure about enabling zoom but that should get you paging through image views.

Related

Possible to Limit Zooming / Panning Area in UIScrollView?

I have a UIViewController that implements a UIScrollView with the UIScrollViewDelegate. Attached to it is an UIImageView for which the user must crop the photo via zooming it and panning to fill the entire length of the screen. After the user has finished cropping and they hit done, the original UIImage gets sent to the next UIViewController.
I'm wondering, is there anyway, using the original image, to display it in a UIScrollView and allow the user to zoom and pan it so ONLY the cropped area gets shown? IE none of the image that was outside of the cropped area gets shown in zooming and panning? Is there a way to do this without explicitly cropping the image?
This might head you in the right direction: Displaying part of an image
Not to sure if this will work with the way you are displaying it. But if it does it could be a simple solution. You can also read through UIScrollviews and maybe use panGestureRecognizer and pinchGestureRecognizer to limit the area they can zoom and pan.
Set the content size of the UIScrollView to the rect of the cropped area.

rotation of images in UIScrollView

resizing images inside UIScrollView when rotating the iphone.
I have a series of images placed on the UIScrollView (some images are placed one on top of the other). When I rotate the scrollview at some page, the topmost image on the hierarchy is expected to rotate which happens but the image goes to the first page of the scrollView. Any help on what could be going wrong would be appreciated.
thanks
DKV
I think the imageView which is misbehaving w.r.t to its frame is not added into correct super view. I think you should check that all imageView are added onto scrollView (if you want to show one imageView above another imageView make frame of both the imageView same, avoid adding one imageView onto another imageView).

Scrolling horizontally between multiple images using UIScrollView

If we start with the photos app for example. The images can be viewed with a swipe and the images scroll into view as the user swipes.
How is this kind of UIScrollView setup and how are the Images (e.g. from an array) displayed within this UISCrollView?
Are the images added to the scrollview at once or how is this paging look achieved?
Thanks
This can be achieved using a main UIScrollView with pagingEnabled set to YES and containing nested UIScrollViews. Then you can put an UIImageView in each one of these nested scroll views, so you can also achieve zooming by returning it to - (UIView *)viewForZoomingInScrollView:
Also, you can take a look at these samples from Apple:
http://developer.apple.com/library/ios/#samplecode/Scrolling/Introduction/Intro.html
http://developer.apple.com/library/ios/#samplecode/ScrollViewSuite/Introduction/Intro.html

Setting up the (right) views in order to show an image, the details of it beneath it and enable zooming for the image

What I am trying to do is to present an image at the top of the view and beneath it to show the details of it.
By now I am using a UITableView and a UIImageView. The UIImageView is at the top of the View and the UITableView beneath the UIImageView. In the UIImageView I load an image and I want to let the user to pan/zoom it. In the UITableView I show in sections the details of the image. Everything works ok, but when I enable zooming in the UIImageView the image covers parts of the tableView. Moreover, I cannot scroll anymore.
What is the correct combiantion of views for achieving the above requirements?
Instead of the UIImageView I'd use a UIScrollView with the UIImageView embedded in it, this will allow you to setup pan/zoom within whatever view size you want.

Iphone Custom Scrollview indicator

I am currently working on an application for a client, and they have made an odd request. The request involves putting a custom image as the indicator for the scrollview. I am not even sure if this is possible but if it is can you please let me know how one would go about doing that.
Thanks
UIScrollView streches a small, semi-transparent circle image to generate its scrollbars. You can find this image as the first subview of a UIScrollView:
UIImageView *circle = [scrollView.subviews objectAtIndex:0];
However, as I said this image is stretched, and as far as I can tell, only the alpha values are considered when drawing the scroll bars.
So for example if you're only interested in changing the top/bottom ends of the scroll bar, you can try to change this image. However, I doubt you'll be able to do anything interesting.
A possible solution that comes to mind, and this is only a theory, is to add a custom, transparent UIView on top of a UIScrollView. Then you can hide the default scroll bar (by using showsHorizontalScrollIndicator and showsVerticalScrollIndicator), pass the necessary touch events to the UIScrollView to scroll the content, and draw the scrollbars in your custom view.