Searchcontroller only available on iOS 11 or newer - ios

I'm trying to make my app iOS 9 compliant. But I get this error for the navigationItem.searchController:
'searchController' is only available on iOS 11.0 or newer
How can I make this available for iOS 9 without changing every search logic through the app?

You cannot set the navigation item's searchController before iOS 11, but you can certainly use the UISearchController, just as we've done for years. Simply extract the UISearchController's searchBar and put it, yourself, wherever you want it in the interface. If you want it as or in the navigation bar, then put it there. For example, make it the navigation item's titleView.

Related

How to line break long large title in iOS 13?

As title, is there a way to split long large titles in UINavigationBar?
I tried all those methods, working for iOS 11 but none of them seem work to me on iOS 13
How to set multi line Large title in navigation bar? ( New feature of iOS 11)
You can do it by adding a custom view (UILabel) to your title as answered here.

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.

Larger search bar in iOS 11? How to opt-into new style?

I noticed that in the App Store app, the UISearchBar they're using is larger. (see attached) — Currently when I compile for iOS 11b9 using Xcode 9b6, it still uses the old style, which is too small and is clipped by the status bar.
Is there some clean way to enable/mimic this larger variant of UISearchBar, while still maintaining backwards compatibility with older iOS versions?
I did find after the iPhone X announcement (and subsequent video additions to the Developer site) that there is a bit of a workaround necessarily: https://developer.apple.com/videos/play/fall2017/201
For iOS 11+ only:
Apply the UISearchController to the "navigationItem" not the UIViewController itself. Then set it to be "active" (= true).
Ensure this hidesNavigationBarDuringPresentation is true.
Monitor the delegate callback to track when it was dismissed, and then remove it from the "navigationItem" until it's needed again.
... Honestly it seems like this was a bit of an afterthought, but it does work and is good enough for now.

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?

iOS 8.3: UIActivityViewController shows extraneous row

I have a UIActivityViewController for which I have excluded (using excludedActivityTypes) all the UIActivityCategoryAction activity types.
In iOS 8.2, the UIActivityViewController would only show one line, for the UIActivityCategoryShare activity types.
In iOS 8.3, I get an empty line for UIActivityCategoryAction. See the screenshot below where the second line just has "More".
How can I remove the UIActivityCategoryAction in a UIActivityViewController in iOS 8.3?
In iOS 8, UIActivityViewController is still an API that only provides custom functions, but not custom UI. You can't change the way it looks. The only part of the visual style you can change is the icon of your custom UIActivity subclasses. (ref)
This is how Apple implements this, and it cannot be changed as of 8.3. If you really want to avoid the extra row and the "More" button, you can implement a UIActivityViewController replacement. Here are a couple that have been recently maintained:
OvershareKit
URBNShareKit
References:
UIActivityViewController Hide More from Actions
UIActivityViewController on iOS 8 show "more" button with custom activities
Can I exclude "More" Button in UIActivityViewController?
http://getnotebox.com/developer/uiactivityviewcontroller-ios-8/
This is by-design so that users can add back system and third-party actions that they've hidden.
The More is system default. that is used to reordering the application. and for extension(introduce in IOS 8), More button is used to reorder the app as well add application in dialogue. we don't have any control over it.
Hope this help you.
I find a away to remove the UIActivityCategoryAction .
Like that:
demo
As the UIActivityCategoryAction is the second section of a CollectionView ,
You can find collectionView's dataSource and change the implement of the "numberOfSectionsInCollectionView:" by method swizzling.
here is the demo:enter link description here
UIActivityCategoryAction is the second section of a UIColletionView , change the number of section equal to 1 ,and the UIActivityCategoryAction will disappear.
Here is the demo

Resources