Swift: Imitate iOS Settings screen dimming - ios

I'd like to implement a feature similar to what happens in the iOS Settings screen, whereby the screen background dimming is removed if a search result is found:
https://www.evernote.com/shard/s549/sh/01d96373-7ce1-43f5-aed6-a3aea6ce985d/356e9ba510309e1548a4fb384d1bcdcc
I can use dimsBackgroundDuringPresentation when the UISearchController is initialised but is there a way to switch this from true to false as results are fetched and show in the table view?
Thanks

Related

SafeAreas misbehave when presenting a UIViewController

I need to present a UIViewController (ViewControllerTwo) that only supports ".landscape" orientations from another UIViewController (ViewControllerOne) that only supports ".portrait" orientation. If you check the .gif below, you will notice that when the transition occurs it shrinks the content of "ViewControllerOne" and when you dismiss "ViewControllerTwo" the same happens.
The reason why this happens is related to the change of safe areas, which in portrait are different from landscape and vice versa. But if we override supportedInterfaceOrientations of "ViewControllerOne" to just support ".portrait" it should not be informed of the safe area changes if these changes relate to an unsupported orientation right?
Is this a bug/limitation from iOS?
(NO) -> What is the right way to handle this scenario?
(YES) -> What workaround do you recommend to solve this issue in the meantime?
You can check the Example Project here: https://github.com/mantuness/ExampleProject
Check the GIF below:

Swift: Touch not immediately registered for UIButtons located at bottom of UIViewController

I run into a strange behaviour I am not able to solve. If I place a UIButton at the bottom of the UIViewController of the Main Storyboard, touching it is not immediately registered. It takes about 0.5 seconds till the touch gets registered. You can see than from standard UIButtons when they change the text color. I don't have this issue with buttons anywhere else in the UIViewController.
All I did is adding a Vertical Stack View with 15 UIButtons to the Main View Controller of a new App. When I execute the App on an iPhone 6 or iPhone 8 (the actual devices), the lowest button behaves differently. Touching it doesn't change the text color immediately, while it does for all the other buttons.
Did anyone experience the same issue? Is there a way to solve this or did I just find a bug in the framework? I'm using Xcode 9.2 and deployment target is iOS 11.2.
Go to AppDelegate and try adding:
for gesture in self.window.gestureRecognizers {
gesture.delaysTouchesBegan = NO;
}
It will stop the system from checking to see if you are trying to open control centre.

A way to achieve UISearchController appearance similar to Photos app in iOS 11

I would like to update my old iOS 10 application's UISearchController appearance to have effect similar to native Photos app in iOS 11.
But I am not sure how to get such smooth animation of NavigationBar transition from LargeTitle to UISearchController.
UPDATE
I know that there is UINavigationItem's property UISearchController, but it just shows UISearchBar under the Large Title and its appearance with hidesNavigationBarDuringPresentation set to true looks completely different.
Thanks for any suggestions.
In iOS 11 there's a new way to add the UISearchController to the UINavigationItem. Check the documentation from Apple.

UISearchContainerViewController linker failure in iOS 9.1/Xcode 7.1.1

I have severe problems implementing UISearchController wrapped up in UISearchContainerViewController for a universal tabbed bar application.
Basically what I am trying to implement is search like in the Apple music app where UISearchController is not set as a tableHeaderView but is presented upon tapping a magnifying glass button in the navigation bar.
It's very important that the UISearchController is initialised like this: searchController = UISearchController(searchResultsController: searchResultsController) not with nil, as there are all kinds of scopes and searchable content could be core data and server.
I am currently presenting the UISearchController modally which completely screws up the view hierarchy as search happens in UISplitViewController installed in one of tabs (both master and detail view controllers).
This is the linker error.
My deployment target is 9.1 - I have seen on Apple forums here that somebody else had the same problem.
So is it an Apple bug or I should be looking somewhere in my app?

Disabling the Personal hotspot notification

Enabling personal hot spot pushing down the view and related subviews pushing down. How to disable the personal hotspot notification programmatically? (how can i restrict iPhone status bar to original size even when HOT SPOT is on?)
I found rather late that the Personal Hotspot doesn't just add 20points to the status bar, it messes up views that rely on drop points in an animator with gravity. I added code that checks the status bar height before laying out the views. If it's not 20, then it's probably the hotspot, so I just hide the status bar. Not an ideal solution, but works so far.
- (BOOL)prefersStatusBarHidden {
if ([UIApplication sharedApplication].statusBarFrame.size.height == 20) {
NSLog(#"Status bar is 20 so returning NO for hidden");
return NO;
}
NSLog(#"Status bar is not 20 so returning YES for hidden");
return YES;
}
If you disable statusbar then automatically disable Hotspot bar.
The Apple documentation is not very descriptive of the status bar, esp. the 2nd row that appears when you are using hotspot, map, calls, etc.
Even if more than one is running, there is only one additional row.
I don't know how 3rd party apps appear, but the questioner asked specifically about Personal Hotspot which is a system service.
I doubt the display can be controlled by anybody, except when the user turns the service off.
You probably have to do it the "hard" way". You should hide the main status bar, then draw your own custom status bar.
BTW, Apple says not to do this:
Use the system-provided status bar. People expect the status bar to be consistent systemwide. Don’t replace it with a custom status bar.
https://developer.apple.com/ios/human-interface-guidelines/bars/status-bars/
It's an alternative way but it works.
First include a new key in your project's Info.plist:
Status bar is initially hidden: YES
And then, in your AppDelegate, at didFinishLaunchingWithOptions you can set:
[application setStatusBarHidden:NO];
This will hide the hotspot bar during launch screen and then show it again when the app launches.

Resources