Auto adjust layouts after restoring iOS status bar - ios

After initially designing my UIViewControllers in storyboard without a status bar, I have been instructed that we need to put them back in. Now all the layouts overlap the status bar. Is there an easy way to have everything automatically adjust to start with y=0 below the status bar? Moving and re-pinning everything to the top layer guide is going to be both tedious and error prone - seems like it should happen automatically.
I am using Xcode 6.1, targeting iOS 7.1 and later.

I think there is just one way to make a script to rewrite Storyboard XML file. You try to change constraints for one ViewController manually and check the difference.

Related

iOS 11: `UIBarButtonItem`s having placement and usage issues

We have an app that has been around since before the days of storyboards. Prior to iOS 11 everything was fine after we updated it to be 64 bit. We have found two issues when running under iOS 11:
On iPhones the single UIBarButtonItem in the navigation bar's RightBarButtonItems isn't being placed all the way to the right as usual (the left side buttons is in the proper position).
On iPads we have what looks much like a segmented control (but made of individual buttons). It works fine when it is not in any kind of bar, but when it is in a bar it doesn't get touches.
In both cases I have used the UI navigator in Xcode to see that iOS 11 has added a couple extra views between bars and buttons. One of the added views is a bar content view (specific class depends on wether it is a toolbar or navigation bar; _UIToolbarContentView or _UINavigationBarContentView). The other added view is consistent among all kinds of bars, _UIButtonBarStackView.
In issue 1 above the added stack view is adding a very wide zero height view after the right bar button that is pushing the button way to the left (like it is trying to fit on an iPhone 4's screen far). Since the class has an underscore in front of it and isn't listed in the docs it must be a private class so even if I did dig into it and figure out how to keep the extra padding from getting added to the end it would get rejected by Apple for using private API.
I can't be sure what of the new views is intercepting the touches for the second issue but given that they are the only real differences I see between iOS 10 & 11 they seem the most likely culprits.
As I mentioned this was built before storyboards so the UI is built in xib files.
Has anyone run into issues with these new views and found a way to solve them? Or should I just rip out the whole UI and rebuild it?

How To Avoid iOS Blue Location NavigationBar Messing Up My StatusBar?

iOS has a feature that (I'm using both iOS 10 and 11) when you use a location-based app, say Waze, and you put that app on the background, there will be a blue navigation bar with a blue status bar background saying that Waze is currently using your location. Then open up your own project and close the Waze, this will happen.
Any idea how to fix this one? I'm guessing some configuration in the AppDelegate. Something to setup upon making your project active. I've tried the same steps in my other project and I have no idea why does that other project handle it a little better. The other project has a readable status bar but different background color, still quite a mess but better than in this project in the photo.
This is how your app should work:
The status bar is transparent.
Your view controller's main view should underlap the status bar; it should be fullscreen.
Your views should use autolayout to respond to changes in the size of the top bars (they should be pinned to the top layout guide or, in iOS 11, the top of the safe area).
You are not doing that correctly, so your app does not behave correctly when the status bar size changes due to the location manager bar. You probably have the same problem with phone calls coming in. You can easily test in the Simulator by choosing Toggle In-Call Status Bar.

How to smoothly translate view in iMessage extension in iOS 10?

I have issue when I try to push view controller in willTransitionToPresentationStyle:. The view was blinking for a split second before it fully expanded. It might be a small glitch or bug since iOS 10 and Xcode 8 are still in beta. But when I manually requested to change presentation style to MSMessagesAppPresentationStyleExpanded by calling requestPresentationStyle: after I push view controller, it went to expand mode more smoothly. Does anyone have similar issue?
I have had similar problems with transitions in iMessage apps. I think this should improve considerably when iOS 10 and Xcode 8 come out of beta, but for now we have to deal with Xcode's bugs.
There's a few things I've done to make this look better. Inside my extension I have a method that checks the presentation style every time the view changes. This method manages two different UIs - one for MSMessagesAppPresentationStyleExpanded and one for MSMessagesAppPresentationStyleCompact. This method hides and shows specific views accordingly. In my compact UI I have a button that allows the user to expand the interface by clicking it (this is basically the same as clicking the up arrow at the bottom right of the screen).
I've noticed that if you let the user expand the messages app after the view has been loaded for a while the transitions are much smoother and less buggy. Not sure why this is the case, but you should give it a try. Also, I've found segues to be extremely buggy, so that's why I went with keeping everything on one view controller.

iPad UIViewController subview reset issues

I am not really sure how to phrase this question but to keep it simple;
I originally started my app for iPhone but now made it universal. Being that did that, I started making iPad.xib files as well... Everything is complete now and everything is working how it should except ONE thing...
On the Controllers, I have an instructions button, (button that when touched, a uiview gets added to the center of the screen and says the instructions).
That all works great but for some reason when I touch it on one of the new iPad Controller (from the iPad xib) all the buttons that were moved around the view prior to touching the button, start to revert back to the initial position...
I do have a function that makes them do that, but to my knowledge, it is not being activated when this instructions button gets touched. If it were, I'm sure this "error" would also happen in the iPhone simulator...
Anyone have any idea? I keep looking at different solutions but can't really figure this out.
Thanks!!
This is most likely due to auto layout. If you change the frame of a view by setting frames, when the view updates (for any reason), the views will revert to the frames that are determined by their constraints. To fix the problem, you should move your buttons around using constraints, or turn off auto layout. While turning off auto layout is the easy way to fix this, you really should learn how to use that system.

Is this the right way to make an iPad app full screen?

I want to disable the status bar in iOS to make my app full-screen. I managed it but I'm not sure I did it correctly.
Here's what I did:
In IB, set the Simulated Metric for Status Bar to None
Added an entry in the Info.plist UIStatusBarHidden = YES
Moved my views around in IB so they fill the screen.
I'm not using OpenGL or anything like that, it's just a straightforward Cocoa Touch app which, like many others of a similar type, benefits from having access to every pixel on the screen.
To my shame I got the technique from one of those omnipresent 'tutorials' that litter the web like the dust bunnies under my bed. It was dated 2009. Is there a more modern, approved technique I should be using instead?
If it helps I'm targeting iOS 5 only.
The statusBarHidden property of the shared UIApplication object controls whether the status bar is visible. The UIStatusBarHidden entry in the app's Info.plist sets the value of that statusBarHidden property when the application is launched. You can change the property's value to hide or show the status bar while your app is running.
These are the current methods for controlling the status bar's visibility as of iOS 5.0.1.

Resources