Get UIButton labels to move under button image on device rotation - ios

I have some UIButtons that when shows in portrait look like this
When I rotate the device to landscape, I want the label to be underneath the image.
I've seen this answer to getting the label beneath the button image - Label under image in UIButton but can't figure out how and where to implement this on device rotation that is safe.
My view hierarchy for this section looks like this with the UIScrollView as subview of the main UIView
I am targeting iOS 8 and using AutoLayout. I have seen some answers using layoutSubviews for other questions that do something similar but I've seen that layoutSubviews will be called on each rotation. I need this to only happen on landscape layouts.

Related

Disabling autorotation for specific UIView iOS 12

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

Popover view with arrow on iPhone

I need to present a UI in a popover with arrow which has few controls that works on both iPhone and iPad. I am not sure what is the best way to do this that works correctly with Autolayout and resizing. Let's say I have a UIButton, UISlider, UIButton, UISlider in that order which are equally spaced vertically in the view, how do I set Autolayout constraints and present the view as popover that adapts to resizing? There are essentially two questions here -- how to display a view as popover with arrow and how to use autolayout to adapt to presentation size.

UITableViewCell accessory chevron not right-aligning in iOS7

I am attempting to upgrade a client to iOS7 but am having trouble with the accessoryType. As you can see here, when I launch in standard portrait mode it looks fine (the green background is something I applied to demonstrate how the UIViews are resizing):
As you can see the chevron is properly right-aligned. Now, if I rotate the device:
The chevron does not properly align itself at the right-edge of the screen. I tried applying an autoresizing mask to the accessory view, and about 10 other things, to no avail.
When I launch in iPad mode the chevron does not right align either in portrait or landscape mode.
I am setting this chevron by doing the following in the constructor of a custom UITableViewCell:
self.accessoryType = UITableViewCellAccessoryDisclosureIndicator
Note that scrolling the cells completely off the screen, then letting them fall back on-screen, causes the chevron to draw correctly right-aligned.
Can anyone suggest how to right-align chevrons properly in iOS7?
Figured it out -- it's because I stupidly forgot to include a call to [super layoutSubviews] in my override of
- (void) layoutSubviews
Problem solved!

UIView inserted into UIWebView's scrollview, is not clickable in landscape mode

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

Programmatically change frame of the UIkeyboard after rotation

Since i have a complex hierarchy of views i handle the rotation manually with CGAffineTransformMakeRotation.
Everything rotates in harmony, status bars, navigation bar etc. The only problem is, if the keyboard was on screen before rotation, it gets the orientation of the satiates bar but its size is not right.
How can i force it to fill the entire width and get the right height?
I tested with a single test UIview and it looks likes this.
http://dl.dropbox.com/u/15251533/iPhoneSimulatorScreenshot_20120430_133558.png
I found a simple approach to get rid of this situation.
If you call resignFirstResponder on the Textfield and afterwards becomefirstresdonder consequently.The keyboard appears in the right position after rotation.It also does not disturb the animation if you have one.

Resources