I have a problem that is bugging me like hell. I have a custom view on top of my apps main view for settings configuration. The background of this view uses a UIVisualEffectView. However, my app supports both Portrait and Landscape mode and when changing the orientation, the auto-resizing doesn't work properly for the blur effect.
This is what I mean, changing orientation in the simulator with slow animation set to on (look at whats happens in the bottom of the view):
https://www.dropbox.com/s/bgtx8ygdawkx8be/BlurProblem.mov?dl=0
I have tried setting different content modes and resetting the auto-resizing value, but nothing seems to help.
How can I get the UIVisualEffectView to resize correctly?
Try and set the frame in your viewDidLayoutSubviewsmethod. That way your frame gets set after your view is in place.
Related
How do I allow one subview of my view controller to autorotate on an orientation change, but keep the others static. I'm trying to get an effect similar to the native camera app where the capture and switch cameras buttons (along with all the others) stay in their locations and just rotate accordingly. The SnapChat app also does this where the UI layer that pops up after you take a photo autorotates but the other views do not.
I seemed to be able to get close following the answers here: Disable autorotate on a single subview in iOS8, however, while this prevents them from rotating, it jumbles up their positions.
I think you have to use
(i) autolayout to set constraints on view by fixing its position or width height.
for setting orientation for portrait and landscape you have to use size classes
(ii) Another trick is you can use UIViewController to fix orientation using its mask orientation delegate. then add it add child of other UIViewController
I have iPad application which uses iOS7 SDK with auto-layout.
my main view have a sub view which is a UITabBarController which programmatically creates it's view controller's (storyboard.instaniateViewController..).
Inside the views - when i'm in portrait mode - everything is fine. but when i move to landscape mode - the view's width is changed correctly, but the view's height remains as in Portrait mode.
The result is that my screen is truncated in a height.
Any ideas why it happens? constrains seems fine.
I can change it by programmatically change the vie's frame, but it doesn't seem right.
Thanks
OK, i see what the problem was - somewhere up the view's hierarchy was defined:
[viewController.view setAutoresizingMask:UIViewAutoresizingFlexibleWidth]
and that meant that the height was not flexible of course. the fix is easy once i saw it:
[viewController.view setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight]
I have a Table View inside of my View, The table view is set to "Scale to Fill" which is how I have been working with these in the past without issue. The problem is that this time around when I have the table view loaded up in portrait mode, it looks and behaves just like a table view should, but when the orientation is rotated to landscape this is what I see:
Instead of the list behaving as it normally would its sticking to a portrait orientation that can still be scrolled, but portrait nevertheless. I need this table to fill around the perimeter of the green box.
I have tried setting the mode to : "Aspect Fit" and "Aspect fill" in storyboards but no luck so far.
How can i fix this issue? Please be as detailed as possible.
I had simply overlooked my autosizing settings for the table view.
so basically, for reasons in this answer ive put a UIView inside a webview so that it acts as a header to the view. its works perfectly for ipad, but on iphone when the webview is rotated landscape, the header UIView isnt clickable.
ive tried in the - (void) didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation to explicitly set the userInteraction = true of the header view but this didnt work.
i tried removing it from the superview and adding it back, but to no avail.
i have some debug code that lets me see the class of the view im clicking on, and when i click on the header view i can see its clicking on the scrollview behind it (which is part of the webview). so it just seems to be ignoring the view completely (even though it works in portrait mode, and works in landscape and portrait on ipad).
does anyone know why the click events are going straight though the uiview?
update:
something interesting ive found is that if the webview doesnt resize when the view rotates, then the header is still clickable, so it must be something to do with the resizing of the webview screwing things up
also, the background from the scrollview is like coming through the header view it seems (header = grey, scrollview = yellow) pics here. when rotated back to portrait the grey shows up again and is clickable
Give the scroll view a background color to see where it is. If the button is outside of the scroll view it is still visible (if clipsToBounds is NO, which it is by default) but not clickable.
Find out where the superview of the button is and make the resizing in a way that it is big enough after resizing.
strangest solution, but instead of having the header view autoresize in all directions, i set it like so
something strange must have been happening and making its frame set wrong somehow
I have a layout working fine in Xcode storyboard for a Master-Detail splitview app but when I run it in the Simulator or on an actual device it appears slightly messed up and I have no idea why.
The image in Xcode looks like this;
The layout in Simulator and Device looks like this
This is almost certainly a problem with the autoresizing settings of your subviews (aka "Springs and Struts").
You are building a UISplitViewController-based application. Note that the dimensions of your Detail View Controller's frame are different when your app is running in portrait vs landscape mode. In your storyboard screenshot above you see the landscape-sized frame. The screen capture from your simulator shows the portrait-size frame. You'll need to set the struts and springs of your subviews (the UIPickerView, the brushed metal buttons, the white box below, etc) so that these elements resize (or not) and maintain their relative (or absolute) position in the parent view.
The easiest way to do this is to set the values in your storyboard, using the Size Inspector in the right column. Select which element you want to change settings for and then look for this:
By clicking on the red arrows inside the inner box you will toggle on/off the "springs", which determine whether your subview expands when the parent view expands, or whether it maintains its original size when that happens. By clicking on the outer red I-bars you will toggle on/off the "struts", which determine whether you subview will maintain a fixed distance from its parent view's edge when the parent view's size changes. Setting the right combination of these will make your view to look correct in both portrait and landscape orientations.
You can also change these settings programmatically in your code by setting the view's autoresizingMask property. See for reference:
http://developer.apple.com/library/ios/DOCUMENTATION/WindowsViews/Conceptual/ViewPG_iPhoneOS/CreatingViews/CreatingViews.html#//apple_ref/doc/uid/TP40009503-CH5-SW5