I created a custom "component" made up of UIView and it gets added as subview on any visible view. What I found strange is that when it get added to a view the second time, the width got increased by 1 pix. This caused a problem when it expanded the background image and causes the image to blur out.
Any ideas why a view will get expanded (or shrink) when added to another view?
The issue may be related to the location of the view.
Perhaps one of these stories will shed more light on the issue:
Fixing Blurry Subviews
Why does a PNG image sometimes get blurry depending on its position in a view
Related
For a layout made of some views stacked in each other, which are all subviews of the UIView and I wanted to know how to automatically size the main UIView which may be multiline once the app is live and updates come in. UIView width is fixed.
I believe the view (UIView) does size itself so i dont think you will face this issue. Just try to not constrain the height and make sure you select appropriate stack view while doing this since you got multiple. Hope this helps as i assume that you are not using collection view for this matter!
I would like to use a Map Kit View has a subview of a View Controller that occupies only a portion of the screen, rather than as a fullscreen view.
I am unsure if the following is a bug that I should report, or if I am missing some vital knowledge on how to use Map Kit Views. The easiest way to explain the issue is through pictures.
In the first screenshot I have setup two subviews, a UIImageView and a MKMapView, on an otherwise blank View Controller using Interface Builder. Both subviews have been constrained in the same way, i.e. height, width, constrained to the top or bottom of their superview, and horizontally in the container. Xcode give no errors.
Screenshot before issue:
The second screenshot is after I restart Xcode. The UIImageView is the same, however the MKMapView has increased its width and height to 1,000. Xcode gives the following error: Height and vertical position are ambiguous for "Map View". Updating the frames does not restore the correct layout. To fix the issue, the MKMapView needs to be manually resized to fit into the ViewController, after which updating the frames restores the layout to that shown in the first screenshot. Restarting Xcode causes the issue to repeat.
Screenshot after restarting Xcode:
I am using the latest version of Xcode 8 available from the App Store.
Update:
This bug has been fixed in Xcode 8.1
This seems a bug and for workaround you can add a simple UIView instead of MKMapKit and after adding the constraints change the class of the view from UIView to MKMapView. Although you won't be able to set the properties of this map view from storyboard but you can set it in the code using it's outlet.
I request you to raise this as bug #https://bugreporter.apple.com
So I have a UIScroll view with constraints which position it to the outer borders of the root view - Check
Inside of the UIScrollview I have a VIEW which serves as container for the scrollview.
The issues I'm having is that this view is that even though the bottom constraint is set to equal to the bottom of the scrollview it collapses to a height of 0 in the interface. This hides all of the views inside of the container view making is almost impossible to build the interface...very annoying..what am I missing here?
here is my constraint chart...this is really got me pulling out my hair.
See how the "view" height is 0 and also the Important Message goes to 0 height as well.
I attach a screenshot of my project's document outline which shows whole list of autolayout configurations.I think it will help you to figure out your problem.
enter image description here
I have a UIToolbar in IB with a custom UIBarButtonItem that is set to an image. The image height is larger than the UIToolbar height. The image does not load for some reason. Attached is a screenshot.
You should avoid using subviews that are larger than the parent view - even if it does work and draws the view outside of the bounds, you cannot always count on it because the clipping is skipped for performance reasons and depending on the drawing order the overlapping part of the subview might be covered later. Second problem is that only the part within the frame of the superview is able to handle the touch events.
As to why you don't see your image, it's probably a different problem, I doubt it has something to do with it going outside the frame. Post your code to get more feedback ;)
I'm trying to get a UIView to expand (with animation), sort of like an accordion menu. I can get the animation working fine however the issue is the subviews of the UIView are expanding past the bounds of the UIView.
For example, the view has an UILabel in the top-right corner with a height of 16. Assume the UIView height is 0 at the beginning of the animation. One would expect that the content of the view be hidden and gradually reveal as the UIView grows. Once the height has reached 8, for example, half the label should be visible. However that isn't the case - rather, the label is visible the whole time, regardless if it's height extends outside of that of it's parent view.
Any ideas how to resolve this?
Okay, I had to set the clipsToBounds property to true. I spent some time googling before making the question but didn't have much luck until I saw it in the Related section of my question.