I modified Apples example UISearchController project to allow it to work with iPhone X by embedding the UISearchController into the UINavigationController as apple suggests like:
if (#available(iOS 11.0, *)) {
self.navigationItem.searchController = self.searchController;
} else {
self.tableView.tableHeaderView = self.searchController.searchBar;
}
Everything works as expected, however when I remove the status bar of the project things seem to break. When you tap the search area the NavigationBar disappears and you can even slide the search result table up behind things like the image shows. Having the status bar in the app fixes things.
Modified project here: https://www.dropbox.com/s/6fdtwm361cy8e98/TableSearchwithUISearchController.zip?dl=0
Even on other phones hiding status bar the search field is too close to the top now:
I want the same behavior and spacing with the status bar hidden as with it showing, anyone know what the issue is?
While not ideal, setting the UISearchController property hidesNavigationBarDuringPresentation to false helps in providing a non-broken user experience. Found the suggestion here.
Related
Since iOS15 the QLPreviewController added some additional BarbuttonItems on the top-right side when I'm previewing a PDF-file. It added a search-button and a draw-button (the one where you can draw lines on it). It's actually pretty cool that they added it, but the Share-button is now missing, since it doesn't fit there anymore.
At least on my iPhone, because on my iPad there's enough space for three of them.
Now normally, they show the barbuttonitems that don't fit on an additional navigation bar at the bottom, but in my App the whole navigationbar at the bottom doesn't show up at all. However, it does show up if I tap it once in the middle--which makes everything but the document disappear--and then tap the middle again. Then the bottom navigationbar suddenly shows up as well, including a perfectly working Share-button.
Screenshot of the issue:
I found out that my problem was the UITabbarController at the bottom. Once I tried the functionality to hide the tabbar on push, the bottom navigationbar with the Share-button is immediately shown. It's still a bug and I'll file one at Apple, but the current solution is quite okay.
Here's the code:
let vc = OverviewsQuickLookViewController()
vc.dataSource = self
vc.hidesBottomBarWhenPushed = true
self.navigationController?.pushViewController(vc, animated: true)
I hope this might help someone!
Screenshot of the solution:
I am using Swift 5, testing on a 4K Apple TV.
I am using the UISearchController without subclassing. I am trying to display a white search bar and keyboard on a dark background. So I set:
self.searchController.searchBar.keyboardAppearance = .dark
(I've tried this in viewDidLoad, viewWillAppear and viewDidAppear)
This creates a search bar and keyboard that looks like:
Then if I hit the menu button to leave my app and go back to the Apple TV home page and resume the app it changes the keyboard bar black:
Any ideas what is going on here?
(Note: When running this on the Simulator in Xcode the search bar stays white after backgrounding, I don't know why but it only seems to happen on actual Apple TVs)
I'm trying to make an app very similar to Apple's Mac OS App Store where the window's title is not visible but it has a toolbar with icons and labels.
The problem is that when I set the window's title visibility to hidden in my Window Controller, it also hides the toolbarItem labels.
window?.titleVisibility = .hidden
I tried explicitly setting the toolbar to show both icons and labels, but it seems to be ignoring this.
toolbar.displayMode = .iconAndLabel
Here is a screenshot of my app both with and without setting the title visibility:
You can do instead of
self.window?.titleVisibility = .hidden
the following
self.window.title = "" // no title but the labels for toolbar icons are there
you'd need to start with a 'raw'/borderless nswindow and you'd have to draw it all yourself. there is a nice INAppStoreWindow (or it was nice 4 yrs ago ;)) on github that does all to mimic the appstor look and feel
this is my first question on stack overflow. I hope I will get some help :)
I'm currently updating my App to iOS 7 and I'm experiencing some problems when having a SearchDisplayController inside a ContainerView. Actually it looks like the following:
http://cl.ly/image/2Q1d0D0O1K0u
The whole content with the search bar is placed above the previous ViewController as a ChildViewController. It is it's complete own TableViewController. Now when I tap on the search bar it looks really strange with a weird animation:
http://cl.ly/image/1W2m3c1t3340
Even if I try to build this completely in storyboard (Add TableViewController, Add Container With TableViewController inside) I experience the exact same behaviour, without writing any line of code. I'm messing around with this issue for two days now and I'm not having a clue. Probably this is an iOS 7 bug? Using iOS 6 it works flawlessly.
Got it working using the following code:
if (floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_6_1) {
self.edgesForExtendedLayout = UIRectEdgeNone;
}
Odd that I read about that a ton of the time in case when the search bar overlaps the status bar. Don't know why I didn't try this earlier.
The HIG (p.47) says that I have to be able to handle the double-height status bar that appears during phone calls or voice recordings.
How exactly do I handle this situation?
I really only have 1 screen where a keyboard with toolbar over it underlaps a textfield when the double-height status bar shows - on other screens things are just a bit scrunched up but useable.
If I could detect that a double-height status bar exists, I could maybe adjust the placement of the textfields or make them temporarily shorter but is it possible to detect when the double-height status bar is there?
EDIT: Maybe if there were a way to get the absolute coordinates of a known thing, like the nav bar, and if it was +20 pixels off, I'd assume that the double-height status bar is present. Thoughts?
And a secondary question, if this (or anything) works, I'd just like to hide the regular status bar using
[[UIApplication sharedApplication] setStatusBarHidden:YES animated:NO]
but I don't want to hide both - basically a lazy way not to have to touch any of my screens - if the double is there, make it a single again by hiding the regular status bar. Will the above code hide both?
You can monitor these call-backs of UIApplicationDelegate:
application:willChangeStatusBarFrame:
application:didChangeStatusBarFrame:
And it's easy to test this in the iphone simulator: Hardware->Toggle In-Call Status Bar
Depending on your situation, your views and the things in them can resize automatically to fit the space - check the View Size area of the inspector window in Interface Builder on various objects
This issue also occur when user use many other utilities like hotspot. To solve this issue I use following line of code ( as I was myself stuck in this ).
self.tabBarController?.tabBar.autoresizingMask = UIViewAutoresizing(rawValue: UIViewAutoresizing.RawValue(UInt8(UIViewAutoresizing.flexibleWidth.rawValue) | UInt8(UIViewAutoresizing.flexibleTopMargin.rawValue)))
Objective C reference for same issue available here