Swift - UIImageViews arranged in UIScrollView - uiscrollview

Hi I have an array with URLS. How to display all images in UIScrollView like this:
I want to fill all space in UIScrollView with these 100 images?

I would suggest using a UICollectionView

Related

Swift Xcode aspect-fit behaviour using AutoLayout on a UIImageView inside a containerView

I have a embedded containerview inside my viewcontroller that leads to a UIPageController. Then the UIPageController loads images from a 3rd VC controller.
So it just a simple image swipe / image carousel.
What I cant get to work is autolayout on the UIImage. My containerview has a maring top 0 right 0 left 0 and a height of 200pt with aspect ratio set.
Bellow it some other information shows eg title / text etc.
But all images appears zoomed in/croped in the containerview.
So how can I make the images scale and fit inside the container view?
Thanks,
set the image view's contentmode to scale aspect fit to see as much of the image as possible.
imageView.contentMode = .ScaleAspectFit

iOS 8 imageView inside scrollView with autolayout not working

This is a very simple ViewController. I have an imageView inside a scrollView. Using autolayout I set scrollview's constraints to its view's edges. Also, imageView mode is AspectFit.
The image is provided at runtime, and it may be a landscape or portrait size. When I run the app, the image doesn't fit the current screen size. It seems that scrollView's boundaries are not being honored, thus only part of the image is being displayed. It used to work on ios7 and xcode5, but it's broken for ios8 xcode6.
Any ideas? I need to keep the use of autolayout whenever possible.
Your going to set the imageviews horizontal constraints and pin them to self.view (the scrollviews parent view) instead of the scrollview.
There is a good example of this here:
Using UIScrollView with Auto Layout in iOS
Try this to zoom out completely
[self.scrollView zoomToRect:self.imageView.frame animated:YES];
Have you tried a call to imageView.sizeToFit() in viewDidLoad? My impression is that imageView's size is fluid until the outlets are set. A call to sizeToFit forces the issue.

UIView backed by CATiledLayer in UIScrollView doesn't scroll initially

I'm adding a CATiledLayer backed UIView in UIScrollView.
When the view is first loaded, I'm trying to fit the UIView, by setting the zoomScale of UIScrollView - this fits the UIView and the layered contents.
I'm having a method to fetch the tiles of image and I'm rendering them in drawLayer:inContext:
Now even if the contentsize of scrollview/frame of CATiledLayer view is greater than UIScrollView, it doesn't scroll initially.
The moment I try to zoom by pinching the screen, I'm able to scroll perfectly.
I can't scale the CGContext in drawLayer:inContext, since the context I receive is of a tile and not whole image and I have 20 tiles which make up my image.
At the end of the initWithFrame of the PDFScrollView i added the line:-
self.zoomScale = 1.0;
This worked for me.
The code is pretty much doing the same stuff as apple example
http://developer.apple.com/library/ios/#samplecode/ZoomingPDFViewer/Introduction/Intro.html%23//apple_ref/doc/uid/DTS40010281-Intro-DontLinkElementID_2
which also doesnt scroll on loading

Image maps in iPhone app

I want to impliment a clickable pie chart in iphone app. I have an image for this but i want to know how can i specify clickable areas using UIImageView or any other component. I don't want to use HTML image map.
A simple solution could be to add transparent buttons on top of your image.
UIButton *transparantButton = [UIButton buttonWithType:UIButtonTypeCustom];
transparantButton.frame = CGRectMake(100, 100, 50, 50);
[transparantButton addTarget:self action:#selector(clicked) forControlEvents:UIControlEventTouchUpInside];
[imageView addSubview:transparantButton];
You can probable try by placing custom buttons over the areas you want or detect touch and based on the location of touch u can perform necessary actions.
Note: The method using buttons is better if the number of such clickable regions is small.
you can create image map for iphone using jquery mobilymap: Jquery Map

UIWebView performance compared to UIScrollView with many labels

in an iOS app I have to display a list of text items that are stored as strings in an array. Since the lines of text would be formatted differently (size, color), I tried two different approaches:
create an UIWebView, make a htmlstring at runtime from the strings in the array and format it with a loaded css file
create an UIScrollView, and create an UILabel for every string AND add an UIImageView with an image of a dotted line after each label (which I do with css in the approach above)
I expected very poor performance from the second approach. BUT it seems the scrollview with the labels (ca. 100) an images scrolls smoother and is more responsive than the webview.
How could that be? I do nothing in the background, just display this view. Thanks a lot!
If I'm not mistaken it's because UIWebView doesn't pre-render anything.
Meaning - UIScrollView caches all your data for smooth transition while UIWebView renders it as it enter the view.

Resources