UIView backed by CATiledLayer in UIScrollView doesn't scroll initially - uiscrollview

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

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.

subview of IKImageView appears below image instead of above

I have a IKImageView and a NSImageView as a subview. Subviews are supposed to get drawn above their master view. I tried an NSImageView with the same subview, and it worked fine, but I really need to be able to move the image around with the mouse, and zoom it with a slider, and I think IKImageView is a bit easier.
What happens is this:
As you can see, the small picture (subview) is below the image on the IKImageView, but in front of the background of IKImageView.
How can I fix this?
ps: Do you think I should use NSImageView? If so, how would I move it around, and zoom?
call addSubview again everytime after I set the IKImageView's image.
That work for me.

Hide NSView overflow

I'm a web dev guy. The overflow:hidden CSS property tells the render engine to not draw the current view's content across the parent's borders.
In my current project, I have a custom NSWindow with a custom NSView with rounded corners by using NSMakeRect, overwriting drawRect: and so on. A WebView inside the NSView is strechted across the entire NSView frame.
Now the WebView 'overflows' the rounded corners of theNSView`. What I do like to have is that the WebView has the same mask as the NSView.
How would you do that?
Also make sure your view sets clips subviews to true. As far as I understand you, this is what you are looking for, and prevents f.ex. images to reach out of the parent view.
[self.view setClipsToBounds:YES];
You can set a corner radius to the layer of a view.
myView.layer.cornerRadius = 5.0f;
You'll have to add QuartzCore.framework.

OPENGL/ES 3D model zoomed doesn't pan correctly in UIScrollView

I have a 3d model rendered in a UIView. When I pinch the model it zooms correctly, but when zoomed in I'd like the ability to pan/scroll the view so that I can see the parts of the model which are outside the boundaries of the view. I switched the UIView to a UIScrollView, and on the pinch event is update the content size with the scale factor. This works great and I can now scroll the view. My problem is that panning to the outer edges of the content view still shows the 3d model still clipped at the size of the initial view. I hope this makes sense...
Does anyone have an idea what might be needed to render the zoomed in parts of the chair, which should now be visible (after panning)?
I was able to get this working after setting the UIView.bounds as well as the UIScrollView content size. That is, the scrollview contained a uiview, which contained the 3d model. I was resizing the scrollview, but not the uiview. They both needed to be set in order for this to work.

Resources