I create a UIScrollView, in which I put a UIView. Then I add some objects which are subviews of the view I added to the UIScrollView, so that I can zoom properly all the objects within the scroll.
The point is that I have an UIImageView as a subview of the mentioned view, which contains an image which is adapted to the screen size by using "imageView.contentMode = UIViewContentModeScaleAspectFit;" property.
Initially, in portrait orientation, the image fits with the screen width, so you can't scroll to left or right. When I change orientation to landscape, image fits with screen top and bottom. Then my problem. You can scroll up and down a little bit the image, as if it preserved some of the top and bottom padding from the portrait orientation.
But, if I try to zoom out, as the min zoom I setted was 1,0, the image recovers its initial size. Then you can't zoom out anymore when the zoom scale is 1.0. The 'virtual' padding is gone!
It seems as if it needed some kind of refresh.
The same happens when I keep changing orientation for portrait and landscape. It only works correctly when app loads.
I tried setting "myUIScrollView.zoom = 1.0;" in "didRotateFromInterfaceOrientation" method (when the image was not zoomed) and it worked, the 'virtual' padding again was gone.
It seems that it needs a refresh once orientation changes.
Any clue about what I'm doing wrong?
Related
I'm trying to use storyboard and layout constraints to align the footer image to the bottom of the view but when running on device it's hovering high above the bottom. The image is aligned with 0 margin to the superview. The view hierarchy is Controller->View->ScrollView->View->FooterImage. The image is bigger and scaled with content mode set to "aspect fit".
The constraints set on the image is sufficient, but I guess the constraints set on its super View is incorrect.
If you want to display the image at bottom you also need to make it superView align to the bottom of the ScrollView , and the same on ScrollView.
Check my previous answer here : https://stackoverflow.com/a/46539635/8187800 .
In our OS X application, we have enabled window shadow by view.window?.hasShadow = true. This will create a fine shadow over NSWindow. We have created a hole in the application by a custom view to see the background through it, via its mask layer.
Our problem is that the shadow is visible in the hole region too. Can we make the shadow not appear in the transparent region. We have searched, but didn't get anything to clip window shadow at certain area.
This shadow is creating some problem in the application
We have given a button to collapse/expand the view which have the hole. So the hole will enlarge and shrink according to that. At this time window will not recalculate the shadow. We have tried the view.window?.invalidateShadow(). But it doesn't has any effect.
We are drawing some texts over the transparent region. When the expand collapse happens we can see the traces of the text drawn. It will always be there.
Every thing comes fine if we resize the application, which will recalculate the shadow. How we can overcome these issue. What will be the work around.
Got another issue with UISplitViewContoller on iOS 8.
When in portrait, and the displayMode is UISplitViewControllerDisplayModePrimaryOverlay, when you rotate to landscape the secondary view controller's view doesn't resize correctly during the rotation animation. Once the rotation is done, the size is adjusted to fit the screen space and it snaps into place which is quite jarring.
However, if the display mode is UISplitViewControllerDisplayModePrimaryHidden when the rotation occurs, the secondary view's size is adjusted during the rotation animation and everything looks and works as expected.
This occurs even with the out of the box Master-Detail template project from Xcode 6.1.
Any thoughts on how to get the secondary controller's view to size correctly during the animation when the primary overlay is visible?
I have an UIScrollView which contains one UIImageView. Everything is working correctly, I can zoom in and out, when zoomed in I can pan around, etc.
The problem that I am unable to solve is how to pan a zoomed out image around the screen. The user needs to be able to zoom the image out until it's small, and then move that small image to any point on the screen. Sadly, it's stuck in the center of the screen (usually, it would be stuck in the top left corner but I did fix that problem).
There are a couple of things you need to do here. I suggest doing them in viewWillAppear rather than viewDidLoad because if you're using storyboards, it doesn't work quite right in viewDidLoad.
First, you need to set the content size property of your scroll view to be the size of the photo itself because you want the entire area of your photo to be scrollable.
self.scrollView.contentSize=self.photoShown.size;
photoShown is UIImage. scrollView is a UIScrollView
Second, you need to set the frame of your UIImageView that houses your image to be the size of your image:
self.imageView.frame=CGRectMake(0,0, self.photoShown.size.width, self.photoShown.size.height);
if you haven't done this, then the frame of the UIImageView is the size of the screen itself and there is simply nowhere to pan. That's why it needs to be bigger, so you can pan to the regions not currently shown on screen.
I've been trying to animate a uiwebview by making its frame shorter height using the UIView animateWithDuration:animations: method. I successfully shorten the uiwebview by making the frame property equal to a shorter height however when i scroll to the bottom of the uiwebview I find a grey box.
After I animate the uiwebview to be shorter height I animate the uiwebview to be longer height (back to normal height it was originally), and the grey box disappears (and it's animated, too).
I'm wondering if anyone has any idea how I can get rid of the grey box at the bottom of the uiwebview when i animate it to be shorter (via the frame property).
I've tried reloading the webview (via the reload method).
I've tried setNeedsDisplay.
I've tried setting the contentMode to redraw.
Scale Pages to Fit is off (I'd rather that it be off because otherwise my content shrinks too much).