Broken UISearchBar animation embedded in NavigationItem2019 Community Moderator ElectionSuccessive view controllers with search bars in their navigation items cause obscuring of view when animating push and popUISearchController in NavigationItem iOS 11 Apple wayUISearchController with large titles crashes in Tab bar with “Only one palette with a top boundary edge can be active outside of a transition”Dont animate navigationBar transition when push ViewController with SearchController and before in navigation were too a VC with SearchControllerUISearchController / UINavigationBar shows broken animation when used within UINavigationControllerThe first UITableViewCell's accessary arrow is not showingHow do I animate constraint changes?How to detect tableView cell touched or clicked in swiftDirecting to a different ViewController depending on tableView cell clickedExpand and Collapse tableview cellsUpdate or reload UITableView after completion of delete action on detail viewTableView not displaying text with JSON data from API callTextfield values set to empty when coming back from previous view controllerUISearchBar in control segmentsSwift vertical UICollectionView inside UITableView
Professor being mistaken for a grad student
Instead of Universal Basic Income, why not Universal Basic NEEDS?
PlotLabels with equations not expressions
The use of "touch" and "touch on" in context
Use of プラトニック in this sentence?
What are the possible solutions of the given equation?
Be in awe of my brilliance!
Replacing Windows 7 security updates with anti-virus?
How do I interpret this "sky cover" chart?
Is it possible that AIC = BIC?
How to write cleanly even if my character uses expletive language?
How to simplify this time periods definition interface?
It's a yearly task, alright
Possible Leak In Concrete
Rules about breaking the rules. How do I do it well?
Humanity loses the vast majority of its technology, information, and population in the year 2122. How long does it take to rebuild itself?
Official degrees of earth’s rotation per day
Is a lawful good "antagonist" effective?
Why using two cd commands in bash script does not execute the second command
How is the Swiss post e-voting system supposed to work, and how was it wrong?
What options are left, if Britain cannot decide?
Making a sword in the stone, in a medieval world without magic
Science-fiction short story where space navy wanted hospital ships and settlers had guns mounted everywhere
Identifying the interval from A♭ to D♯
Broken UISearchBar animation embedded in NavigationItem
2019 Community Moderator ElectionSuccessive view controllers with search bars in their navigation items cause obscuring of view when animating push and popUISearchController in NavigationItem iOS 11 Apple wayUISearchController with large titles crashes in Tab bar with “Only one palette with a top boundary edge can be active outside of a transition”Dont animate navigationBar transition when push ViewController with SearchController and before in navigation were too a VC with SearchControllerUISearchController / UINavigationBar shows broken animation when used within UINavigationControllerThe first UITableViewCell's accessary arrow is not showingHow do I animate constraint changes?How to detect tableView cell touched or clicked in swiftDirecting to a different ViewController depending on tableView cell clickedExpand and Collapse tableview cellsUpdate or reload UITableView after completion of delete action on detail viewTableView not displaying text with JSON data from API callTextfield values set to empty when coming back from previous view controllerUISearchBar in control segmentsSwift vertical UICollectionView inside UITableView
I am experiencing a problem with the new way of adding search bar to the navigation item.
As you can see in the picture below, there are two UIViewControllers one after the other, and both have the search bar. The problem is the animation, which is ugly when search bar is visible on the first view controller but not on the second one. The area occupied by the search bar stays on the screen and suddenly disappears.
The code is very basic (no other changes in the project were made):
(I write primarily in C#, so there might be errors in this code.)
ViewController.swift:
import UIKit
class ViewController: UITableViewController, UISearchResultsUpdating
override func loadView()
super.loadView()
definesPresentationContext = true;
navigationController?.navigationBar.prefersLargeTitles = true;
navigationItem.largeTitleDisplayMode = .automatic;
navigationItem.title = "VC"
tableView.insetsContentViewsToSafeArea = true;
tableView.dataSource = self;
refreshControl = UIRefreshControl();
refreshControl?.addTarget(self, action: #selector(ViewController.handleRefresh(_:)), for: UIControlEvents.valueChanged)
tableView.refreshControl = refreshControl;
let stvc = UITableViewController();
stvc.tableView.dataSource = self;
let sc = UISearchController(searchResultsController: stvc);
sc.searchResultsUpdater = self;
navigationItem.searchController = sc;
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell
var cell = tableView.dequeueReusableCell(withIdentifier: "cell1");
if (cell == nil)
cell = UITableViewCell(style: .default, reuseIdentifier: "cell1");
cell?.textLabel?.text = "cell " + String(indexPath.row);
return cell!;
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int
return 20;
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath)
let vc = ViewController();
navigationController?.pushViewController(vc, animated: true);
@objc func handleRefresh(_ refreshControl: UIRefreshControl)
DispatchQueue.main.asyncAfter(deadline: .now() + .seconds(2), execute:
refreshControl.endRefreshing();
)
func updateSearchResults(for searchController: UISearchController)
AppDelegate.swift:
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool
window = UIWindow(frame: UIScreen.main.bounds);
window?.rootViewController = UINavigationController(rootViewController: ViewController());
window?.makeKeyAndVisible();
UINavigationBar.appearance().barTintColor = UIColor.red;
return true
Ideas?
ios animation uisearchbar ios11
add a comment |
I am experiencing a problem with the new way of adding search bar to the navigation item.
As you can see in the picture below, there are two UIViewControllers one after the other, and both have the search bar. The problem is the animation, which is ugly when search bar is visible on the first view controller but not on the second one. The area occupied by the search bar stays on the screen and suddenly disappears.
The code is very basic (no other changes in the project were made):
(I write primarily in C#, so there might be errors in this code.)
ViewController.swift:
import UIKit
class ViewController: UITableViewController, UISearchResultsUpdating
override func loadView()
super.loadView()
definesPresentationContext = true;
navigationController?.navigationBar.prefersLargeTitles = true;
navigationItem.largeTitleDisplayMode = .automatic;
navigationItem.title = "VC"
tableView.insetsContentViewsToSafeArea = true;
tableView.dataSource = self;
refreshControl = UIRefreshControl();
refreshControl?.addTarget(self, action: #selector(ViewController.handleRefresh(_:)), for: UIControlEvents.valueChanged)
tableView.refreshControl = refreshControl;
let stvc = UITableViewController();
stvc.tableView.dataSource = self;
let sc = UISearchController(searchResultsController: stvc);
sc.searchResultsUpdater = self;
navigationItem.searchController = sc;
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell
var cell = tableView.dequeueReusableCell(withIdentifier: "cell1");
if (cell == nil)
cell = UITableViewCell(style: .default, reuseIdentifier: "cell1");
cell?.textLabel?.text = "cell " + String(indexPath.row);
return cell!;
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int
return 20;
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath)
let vc = ViewController();
navigationController?.pushViewController(vc, animated: true);
@objc func handleRefresh(_ refreshControl: UIRefreshControl)
DispatchQueue.main.asyncAfter(deadline: .now() + .seconds(2), execute:
refreshControl.endRefreshing();
)
func updateSearchResults(for searchController: UISearchController)
AppDelegate.swift:
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool
window = UIWindow(frame: UIScreen.main.bounds);
window?.rootViewController = UINavigationController(rootViewController: ViewController());
window?.makeKeyAndVisible();
UINavigationBar.appearance().barTintColor = UIColor.red;
return true
Ideas?
ios animation uisearchbar ios11
Check in device.. It may be simulator issue. Try withviewDidLoad()
(instead of loadView() )
– Krunal
Sep 19 '17 at 13:47
Nope, on device it is the same.
– BartoszCichecki
Sep 19 '17 at 13:49
And viewDidLoad has the same result.
– BartoszCichecki
Sep 19 '17 at 13:49
add a comment |
I am experiencing a problem with the new way of adding search bar to the navigation item.
As you can see in the picture below, there are two UIViewControllers one after the other, and both have the search bar. The problem is the animation, which is ugly when search bar is visible on the first view controller but not on the second one. The area occupied by the search bar stays on the screen and suddenly disappears.
The code is very basic (no other changes in the project were made):
(I write primarily in C#, so there might be errors in this code.)
ViewController.swift:
import UIKit
class ViewController: UITableViewController, UISearchResultsUpdating
override func loadView()
super.loadView()
definesPresentationContext = true;
navigationController?.navigationBar.prefersLargeTitles = true;
navigationItem.largeTitleDisplayMode = .automatic;
navigationItem.title = "VC"
tableView.insetsContentViewsToSafeArea = true;
tableView.dataSource = self;
refreshControl = UIRefreshControl();
refreshControl?.addTarget(self, action: #selector(ViewController.handleRefresh(_:)), for: UIControlEvents.valueChanged)
tableView.refreshControl = refreshControl;
let stvc = UITableViewController();
stvc.tableView.dataSource = self;
let sc = UISearchController(searchResultsController: stvc);
sc.searchResultsUpdater = self;
navigationItem.searchController = sc;
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell
var cell = tableView.dequeueReusableCell(withIdentifier: "cell1");
if (cell == nil)
cell = UITableViewCell(style: .default, reuseIdentifier: "cell1");
cell?.textLabel?.text = "cell " + String(indexPath.row);
return cell!;
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int
return 20;
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath)
let vc = ViewController();
navigationController?.pushViewController(vc, animated: true);
@objc func handleRefresh(_ refreshControl: UIRefreshControl)
DispatchQueue.main.asyncAfter(deadline: .now() + .seconds(2), execute:
refreshControl.endRefreshing();
)
func updateSearchResults(for searchController: UISearchController)
AppDelegate.swift:
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool
window = UIWindow(frame: UIScreen.main.bounds);
window?.rootViewController = UINavigationController(rootViewController: ViewController());
window?.makeKeyAndVisible();
UINavigationBar.appearance().barTintColor = UIColor.red;
return true
Ideas?
ios animation uisearchbar ios11
I am experiencing a problem with the new way of adding search bar to the navigation item.
As you can see in the picture below, there are two UIViewControllers one after the other, and both have the search bar. The problem is the animation, which is ugly when search bar is visible on the first view controller but not on the second one. The area occupied by the search bar stays on the screen and suddenly disappears.
The code is very basic (no other changes in the project were made):
(I write primarily in C#, so there might be errors in this code.)
ViewController.swift:
import UIKit
class ViewController: UITableViewController, UISearchResultsUpdating
override func loadView()
super.loadView()
definesPresentationContext = true;
navigationController?.navigationBar.prefersLargeTitles = true;
navigationItem.largeTitleDisplayMode = .automatic;
navigationItem.title = "VC"
tableView.insetsContentViewsToSafeArea = true;
tableView.dataSource = self;
refreshControl = UIRefreshControl();
refreshControl?.addTarget(self, action: #selector(ViewController.handleRefresh(_:)), for: UIControlEvents.valueChanged)
tableView.refreshControl = refreshControl;
let stvc = UITableViewController();
stvc.tableView.dataSource = self;
let sc = UISearchController(searchResultsController: stvc);
sc.searchResultsUpdater = self;
navigationItem.searchController = sc;
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell
var cell = tableView.dequeueReusableCell(withIdentifier: "cell1");
if (cell == nil)
cell = UITableViewCell(style: .default, reuseIdentifier: "cell1");
cell?.textLabel?.text = "cell " + String(indexPath.row);
return cell!;
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int
return 20;
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath)
let vc = ViewController();
navigationController?.pushViewController(vc, animated: true);
@objc func handleRefresh(_ refreshControl: UIRefreshControl)
DispatchQueue.main.asyncAfter(deadline: .now() + .seconds(2), execute:
refreshControl.endRefreshing();
)
func updateSearchResults(for searchController: UISearchController)
AppDelegate.swift:
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool
window = UIWindow(frame: UIScreen.main.bounds);
window?.rootViewController = UINavigationController(rootViewController: ViewController());
window?.makeKeyAndVisible();
UINavigationBar.appearance().barTintColor = UIColor.red;
return true
Ideas?
ios animation uisearchbar ios11
ios animation uisearchbar ios11
edited Feb 21 '18 at 23:33
j08691
167k20195215
167k20195215
asked Sep 19 '17 at 13:30
BartoszCicheckiBartoszCichecki
80231839
80231839
Check in device.. It may be simulator issue. Try withviewDidLoad()
(instead of loadView() )
– Krunal
Sep 19 '17 at 13:47
Nope, on device it is the same.
– BartoszCichecki
Sep 19 '17 at 13:49
And viewDidLoad has the same result.
– BartoszCichecki
Sep 19 '17 at 13:49
add a comment |
Check in device.. It may be simulator issue. Try withviewDidLoad()
(instead of loadView() )
– Krunal
Sep 19 '17 at 13:47
Nope, on device it is the same.
– BartoszCichecki
Sep 19 '17 at 13:49
And viewDidLoad has the same result.
– BartoszCichecki
Sep 19 '17 at 13:49
Check in device.. It may be simulator issue. Try with
viewDidLoad()
(instead of loadView() )– Krunal
Sep 19 '17 at 13:47
Check in device.. It may be simulator issue. Try with
viewDidLoad()
(instead of loadView() )– Krunal
Sep 19 '17 at 13:47
Nope, on device it is the same.
– BartoszCichecki
Sep 19 '17 at 13:49
Nope, on device it is the same.
– BartoszCichecki
Sep 19 '17 at 13:49
And viewDidLoad has the same result.
– BartoszCichecki
Sep 19 '17 at 13:49
And viewDidLoad has the same result.
– BartoszCichecki
Sep 19 '17 at 13:49
add a comment |
4 Answers
4
active
oldest
votes
It looks like Apple still needs to iron out the use of the UISearchBar in the new large title style. If the UIViewController
you push to doesn't have its navigationItem.searchController
set, the animation works fine. When navigating between two instances of UIViewController
that both have a searchController set, you get the issue you describe where the height of the navigation bar jumps.
You can solve (work around) the problem by creating the UISearchController
every time viewDidAppear
gets called (instead of creating it in loadView
) and setting navigationItem.searchController
to nil on viewDidDisappear
.
override func viewDidAppear(_ animated: Bool)
super.viewDidAppear(animated)
DispatchQueue.main.async
let stvc = UITableViewController()
stvc.tableView.dataSource = self
let sc = UISearchController(searchResultsController: stvc)
sc.searchResultsUpdater = self
self.navigationItem.searchController = sc
override func viewDidDisappear(_ animated: Bool)
super.viewDidDisappear(animated)
self.navigationItem.searchController = nil
The reason for the asynchronous dispatch is that when setting the navigationItem.searchController
inline in the viewDidAppear
method, an exception is raised:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Only one palette with a top boundary edge can be active outside of a transition. Current active palette is <_UINavigationControllerManagedSearchPalette: 0x7fad67117e80; frame = (0 116; 414 0); layer = <CALayer: 0x60400002c8e0>>'
I know this is only a work around, but hopefully this will help you for now, until Apple solves the issue with navigating between two view controllers that both have a UISearchController
set on their navigationItem
.
3
iOS 11...nice miss Apple.. 😂
– Will Von Ullrich
Sep 26 '17 at 21:00
2
Still get the same crash when switching between tabs in at TabBarController :( Any tips?
– Sunkas
Jul 17 '18 at 14:48
@silicon_valley Do you have any idea how to handle the back action - when on the first screen the search bar is under the navigation bar and on the second the search bar is visible and you tap back - you there is the same glitch
– KoCMoHaBTa
Oct 25 '18 at 15:15
Have you tried setting thenavigationItem.searchController
tonil
onviewWillAppear
andviewDidDisappear
?
– silicon_valley
Oct 27 '18 at 18:09
still present on iOS 12
– Alessandro
Dec 5 '18 at 10:23
add a comment |
My solution for this problem is to update the constraint that is keeping the UISearchBar
visible, when the UIViewController
is being dismissed. I was not able to use silicon_valley's solution as even with the asynchronous dispatch I was getting the crash he mentioned. This is admittedly a pretty messy solution but Apple hasn't made this easy.
The code below assumes you have a property containing a UISearchController
instance within your UIViewController
subclass called searchController
override func viewWillDisappear(_ animated: Bool)
super.viewWillDisappear(animated)
if
animated
&& !searchController.isActive
&& !searchController.isEditing
&& navigationController.map($0.viewControllers.last != self) ?? false,
let searchBarSuperview = searchController.searchBar.superview,
let searchBarHeightConstraint = searchBarSuperview.constraints.first(where:
$0.firstAttribute == .height
&& $0.secondItem == nil
&& $0.secondAttribute == .notAnAttribute
&& $0.constant > 0
)
UIView.performWithoutAnimation
searchBarHeightConstraint.constant = 0
searchBarSuperview.superview?.layoutIfNeeded()
You can remove the performWithoutAnimation
and layoutIfNeeded
, and it will still animate; however I found the animation was never triggered the first time, and it doesn't look that great anyway.
I hope Apple fixes this in a later iOS release, the current release is 12.1.4 at the time of writing.
add a comment |
The accepted answer does solve the problem for some situations, but I was experiencing it resulting in the complete removal of the navigationItem
in the pushed view controller if the first search bar was active.
I've come up with another workaround, similar to the answer by stu, but requiring no meddling with constraints. The approach is to determine, at the point of the segue, whether the search bar is visible. If it is, we instruct the destination view controller to make its search bar visible from load. This means that the navigation item animation behaves correctly:
Assuming the two view controllers are called UIViewController1
and UIViewController2
, where 1
pushes 2
, the code is as follows:
class ViewController1: UITableViewController
override func viewDidLoad()
super.viewDidLoad()
let searchController = UISearchController(searchResultsController: nil)
searchController.obscuresBackgroundDuringPresentation = false
navigationItem.searchController = searchController
definesPresentationContext = true
override func prepare(for segue: UIStoryboardSegue, sender: Any?)
if let viewController2 = segue.destination as? ViewController2, let searchController = navigationItem.searchController
// If the search bar is visible (but not active, which would make it visible but at the top of the view)
// in this view controller as we are preparing to segue, instruct the destination view controller that its
// search bar should be visible from load.
viewController2.forceSearchBarVisibleOnLoad = !searchController.isActive && searchController.searchBar.frame.height > 0
class ViewController2: UITableViewController
var forceSearchBarVisibleOnLoad = false
override func viewDidLoad()
super.viewDidLoad()
let searchController = UISearchController(searchResultsController: nil)
searchController.obscuresBackgroundDuringPresentation = false
navigationItem.searchController = searchController
// If on load we want to force the search bar to be visible, we make it so that it is always visible to start with
if forceSearchBarVisibleOnLoad
navigationItem.hidesSearchBarWhenScrolling = false
override func viewDidAppear(_ animated: Bool)
super.viewDidAppear(animated)
// When the view has appeared, we switch back the default behaviour of the search bar being hideable.
// The search bar will already be visible at this point, thus achieving what we aimed to do (have it
// visible during the animation).
navigationItem.hidesSearchBarWhenScrolling = true
add a comment |
I have added this code in viewDidLoad() and it's working, when I moved in b/w of tabs
searchController.dimsBackgroundDuringPresentation
2
How can this change something? Did you forget appending= false
in your line of code?
– fl034
Oct 11 '18 at 8:31
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f46301813%2fbroken-uisearchbar-animation-embedded-in-navigationitem%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
4 Answers
4
active
oldest
votes
4 Answers
4
active
oldest
votes
active
oldest
votes
active
oldest
votes
It looks like Apple still needs to iron out the use of the UISearchBar in the new large title style. If the UIViewController
you push to doesn't have its navigationItem.searchController
set, the animation works fine. When navigating between two instances of UIViewController
that both have a searchController set, you get the issue you describe where the height of the navigation bar jumps.
You can solve (work around) the problem by creating the UISearchController
every time viewDidAppear
gets called (instead of creating it in loadView
) and setting navigationItem.searchController
to nil on viewDidDisappear
.
override func viewDidAppear(_ animated: Bool)
super.viewDidAppear(animated)
DispatchQueue.main.async
let stvc = UITableViewController()
stvc.tableView.dataSource = self
let sc = UISearchController(searchResultsController: stvc)
sc.searchResultsUpdater = self
self.navigationItem.searchController = sc
override func viewDidDisappear(_ animated: Bool)
super.viewDidDisappear(animated)
self.navigationItem.searchController = nil
The reason for the asynchronous dispatch is that when setting the navigationItem.searchController
inline in the viewDidAppear
method, an exception is raised:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Only one palette with a top boundary edge can be active outside of a transition. Current active palette is <_UINavigationControllerManagedSearchPalette: 0x7fad67117e80; frame = (0 116; 414 0); layer = <CALayer: 0x60400002c8e0>>'
I know this is only a work around, but hopefully this will help you for now, until Apple solves the issue with navigating between two view controllers that both have a UISearchController
set on their navigationItem
.
3
iOS 11...nice miss Apple.. 😂
– Will Von Ullrich
Sep 26 '17 at 21:00
2
Still get the same crash when switching between tabs in at TabBarController :( Any tips?
– Sunkas
Jul 17 '18 at 14:48
@silicon_valley Do you have any idea how to handle the back action - when on the first screen the search bar is under the navigation bar and on the second the search bar is visible and you tap back - you there is the same glitch
– KoCMoHaBTa
Oct 25 '18 at 15:15
Have you tried setting thenavigationItem.searchController
tonil
onviewWillAppear
andviewDidDisappear
?
– silicon_valley
Oct 27 '18 at 18:09
still present on iOS 12
– Alessandro
Dec 5 '18 at 10:23
add a comment |
It looks like Apple still needs to iron out the use of the UISearchBar in the new large title style. If the UIViewController
you push to doesn't have its navigationItem.searchController
set, the animation works fine. When navigating between two instances of UIViewController
that both have a searchController set, you get the issue you describe where the height of the navigation bar jumps.
You can solve (work around) the problem by creating the UISearchController
every time viewDidAppear
gets called (instead of creating it in loadView
) and setting navigationItem.searchController
to nil on viewDidDisappear
.
override func viewDidAppear(_ animated: Bool)
super.viewDidAppear(animated)
DispatchQueue.main.async
let stvc = UITableViewController()
stvc.tableView.dataSource = self
let sc = UISearchController(searchResultsController: stvc)
sc.searchResultsUpdater = self
self.navigationItem.searchController = sc
override func viewDidDisappear(_ animated: Bool)
super.viewDidDisappear(animated)
self.navigationItem.searchController = nil
The reason for the asynchronous dispatch is that when setting the navigationItem.searchController
inline in the viewDidAppear
method, an exception is raised:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Only one palette with a top boundary edge can be active outside of a transition. Current active palette is <_UINavigationControllerManagedSearchPalette: 0x7fad67117e80; frame = (0 116; 414 0); layer = <CALayer: 0x60400002c8e0>>'
I know this is only a work around, but hopefully this will help you for now, until Apple solves the issue with navigating between two view controllers that both have a UISearchController
set on their navigationItem
.
3
iOS 11...nice miss Apple.. 😂
– Will Von Ullrich
Sep 26 '17 at 21:00
2
Still get the same crash when switching between tabs in at TabBarController :( Any tips?
– Sunkas
Jul 17 '18 at 14:48
@silicon_valley Do you have any idea how to handle the back action - when on the first screen the search bar is under the navigation bar and on the second the search bar is visible and you tap back - you there is the same glitch
– KoCMoHaBTa
Oct 25 '18 at 15:15
Have you tried setting thenavigationItem.searchController
tonil
onviewWillAppear
andviewDidDisappear
?
– silicon_valley
Oct 27 '18 at 18:09
still present on iOS 12
– Alessandro
Dec 5 '18 at 10:23
add a comment |
It looks like Apple still needs to iron out the use of the UISearchBar in the new large title style. If the UIViewController
you push to doesn't have its navigationItem.searchController
set, the animation works fine. When navigating between two instances of UIViewController
that both have a searchController set, you get the issue you describe where the height of the navigation bar jumps.
You can solve (work around) the problem by creating the UISearchController
every time viewDidAppear
gets called (instead of creating it in loadView
) and setting navigationItem.searchController
to nil on viewDidDisappear
.
override func viewDidAppear(_ animated: Bool)
super.viewDidAppear(animated)
DispatchQueue.main.async
let stvc = UITableViewController()
stvc.tableView.dataSource = self
let sc = UISearchController(searchResultsController: stvc)
sc.searchResultsUpdater = self
self.navigationItem.searchController = sc
override func viewDidDisappear(_ animated: Bool)
super.viewDidDisappear(animated)
self.navigationItem.searchController = nil
The reason for the asynchronous dispatch is that when setting the navigationItem.searchController
inline in the viewDidAppear
method, an exception is raised:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Only one palette with a top boundary edge can be active outside of a transition. Current active palette is <_UINavigationControllerManagedSearchPalette: 0x7fad67117e80; frame = (0 116; 414 0); layer = <CALayer: 0x60400002c8e0>>'
I know this is only a work around, but hopefully this will help you for now, until Apple solves the issue with navigating between two view controllers that both have a UISearchController
set on their navigationItem
.
It looks like Apple still needs to iron out the use of the UISearchBar in the new large title style. If the UIViewController
you push to doesn't have its navigationItem.searchController
set, the animation works fine. When navigating between two instances of UIViewController
that both have a searchController set, you get the issue you describe where the height of the navigation bar jumps.
You can solve (work around) the problem by creating the UISearchController
every time viewDidAppear
gets called (instead of creating it in loadView
) and setting navigationItem.searchController
to nil on viewDidDisappear
.
override func viewDidAppear(_ animated: Bool)
super.viewDidAppear(animated)
DispatchQueue.main.async
let stvc = UITableViewController()
stvc.tableView.dataSource = self
let sc = UISearchController(searchResultsController: stvc)
sc.searchResultsUpdater = self
self.navigationItem.searchController = sc
override func viewDidDisappear(_ animated: Bool)
super.viewDidDisappear(animated)
self.navigationItem.searchController = nil
The reason for the asynchronous dispatch is that when setting the navigationItem.searchController
inline in the viewDidAppear
method, an exception is raised:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Only one palette with a top boundary edge can be active outside of a transition. Current active palette is <_UINavigationControllerManagedSearchPalette: 0x7fad67117e80; frame = (0 116; 414 0); layer = <CALayer: 0x60400002c8e0>>'
I know this is only a work around, but hopefully this will help you for now, until Apple solves the issue with navigating between two view controllers that both have a UISearchController
set on their navigationItem
.
answered Sep 23 '17 at 18:05
silicon_valleysilicon_valley
1,429915
1,429915
3
iOS 11...nice miss Apple.. 😂
– Will Von Ullrich
Sep 26 '17 at 21:00
2
Still get the same crash when switching between tabs in at TabBarController :( Any tips?
– Sunkas
Jul 17 '18 at 14:48
@silicon_valley Do you have any idea how to handle the back action - when on the first screen the search bar is under the navigation bar and on the second the search bar is visible and you tap back - you there is the same glitch
– KoCMoHaBTa
Oct 25 '18 at 15:15
Have you tried setting thenavigationItem.searchController
tonil
onviewWillAppear
andviewDidDisappear
?
– silicon_valley
Oct 27 '18 at 18:09
still present on iOS 12
– Alessandro
Dec 5 '18 at 10:23
add a comment |
3
iOS 11...nice miss Apple.. 😂
– Will Von Ullrich
Sep 26 '17 at 21:00
2
Still get the same crash when switching between tabs in at TabBarController :( Any tips?
– Sunkas
Jul 17 '18 at 14:48
@silicon_valley Do you have any idea how to handle the back action - when on the first screen the search bar is under the navigation bar and on the second the search bar is visible and you tap back - you there is the same glitch
– KoCMoHaBTa
Oct 25 '18 at 15:15
Have you tried setting thenavigationItem.searchController
tonil
onviewWillAppear
andviewDidDisappear
?
– silicon_valley
Oct 27 '18 at 18:09
still present on iOS 12
– Alessandro
Dec 5 '18 at 10:23
3
3
iOS 11...nice miss Apple.. 😂
– Will Von Ullrich
Sep 26 '17 at 21:00
iOS 11...nice miss Apple.. 😂
– Will Von Ullrich
Sep 26 '17 at 21:00
2
2
Still get the same crash when switching between tabs in at TabBarController :( Any tips?
– Sunkas
Jul 17 '18 at 14:48
Still get the same crash when switching between tabs in at TabBarController :( Any tips?
– Sunkas
Jul 17 '18 at 14:48
@silicon_valley Do you have any idea how to handle the back action - when on the first screen the search bar is under the navigation bar and on the second the search bar is visible and you tap back - you there is the same glitch
– KoCMoHaBTa
Oct 25 '18 at 15:15
@silicon_valley Do you have any idea how to handle the back action - when on the first screen the search bar is under the navigation bar and on the second the search bar is visible and you tap back - you there is the same glitch
– KoCMoHaBTa
Oct 25 '18 at 15:15
Have you tried setting the
navigationItem.searchController
to nil
on viewWillAppear
and viewDidDisappear
?– silicon_valley
Oct 27 '18 at 18:09
Have you tried setting the
navigationItem.searchController
to nil
on viewWillAppear
and viewDidDisappear
?– silicon_valley
Oct 27 '18 at 18:09
still present on iOS 12
– Alessandro
Dec 5 '18 at 10:23
still present on iOS 12
– Alessandro
Dec 5 '18 at 10:23
add a comment |
My solution for this problem is to update the constraint that is keeping the UISearchBar
visible, when the UIViewController
is being dismissed. I was not able to use silicon_valley's solution as even with the asynchronous dispatch I was getting the crash he mentioned. This is admittedly a pretty messy solution but Apple hasn't made this easy.
The code below assumes you have a property containing a UISearchController
instance within your UIViewController
subclass called searchController
override func viewWillDisappear(_ animated: Bool)
super.viewWillDisappear(animated)
if
animated
&& !searchController.isActive
&& !searchController.isEditing
&& navigationController.map($0.viewControllers.last != self) ?? false,
let searchBarSuperview = searchController.searchBar.superview,
let searchBarHeightConstraint = searchBarSuperview.constraints.first(where:
$0.firstAttribute == .height
&& $0.secondItem == nil
&& $0.secondAttribute == .notAnAttribute
&& $0.constant > 0
)
UIView.performWithoutAnimation
searchBarHeightConstraint.constant = 0
searchBarSuperview.superview?.layoutIfNeeded()
You can remove the performWithoutAnimation
and layoutIfNeeded
, and it will still animate; however I found the animation was never triggered the first time, and it doesn't look that great anyway.
I hope Apple fixes this in a later iOS release, the current release is 12.1.4 at the time of writing.
add a comment |
My solution for this problem is to update the constraint that is keeping the UISearchBar
visible, when the UIViewController
is being dismissed. I was not able to use silicon_valley's solution as even with the asynchronous dispatch I was getting the crash he mentioned. This is admittedly a pretty messy solution but Apple hasn't made this easy.
The code below assumes you have a property containing a UISearchController
instance within your UIViewController
subclass called searchController
override func viewWillDisappear(_ animated: Bool)
super.viewWillDisappear(animated)
if
animated
&& !searchController.isActive
&& !searchController.isEditing
&& navigationController.map($0.viewControllers.last != self) ?? false,
let searchBarSuperview = searchController.searchBar.superview,
let searchBarHeightConstraint = searchBarSuperview.constraints.first(where:
$0.firstAttribute == .height
&& $0.secondItem == nil
&& $0.secondAttribute == .notAnAttribute
&& $0.constant > 0
)
UIView.performWithoutAnimation
searchBarHeightConstraint.constant = 0
searchBarSuperview.superview?.layoutIfNeeded()
You can remove the performWithoutAnimation
and layoutIfNeeded
, and it will still animate; however I found the animation was never triggered the first time, and it doesn't look that great anyway.
I hope Apple fixes this in a later iOS release, the current release is 12.1.4 at the time of writing.
add a comment |
My solution for this problem is to update the constraint that is keeping the UISearchBar
visible, when the UIViewController
is being dismissed. I was not able to use silicon_valley's solution as even with the asynchronous dispatch I was getting the crash he mentioned. This is admittedly a pretty messy solution but Apple hasn't made this easy.
The code below assumes you have a property containing a UISearchController
instance within your UIViewController
subclass called searchController
override func viewWillDisappear(_ animated: Bool)
super.viewWillDisappear(animated)
if
animated
&& !searchController.isActive
&& !searchController.isEditing
&& navigationController.map($0.viewControllers.last != self) ?? false,
let searchBarSuperview = searchController.searchBar.superview,
let searchBarHeightConstraint = searchBarSuperview.constraints.first(where:
$0.firstAttribute == .height
&& $0.secondItem == nil
&& $0.secondAttribute == .notAnAttribute
&& $0.constant > 0
)
UIView.performWithoutAnimation
searchBarHeightConstraint.constant = 0
searchBarSuperview.superview?.layoutIfNeeded()
You can remove the performWithoutAnimation
and layoutIfNeeded
, and it will still animate; however I found the animation was never triggered the first time, and it doesn't look that great anyway.
I hope Apple fixes this in a later iOS release, the current release is 12.1.4 at the time of writing.
My solution for this problem is to update the constraint that is keeping the UISearchBar
visible, when the UIViewController
is being dismissed. I was not able to use silicon_valley's solution as even with the asynchronous dispatch I was getting the crash he mentioned. This is admittedly a pretty messy solution but Apple hasn't made this easy.
The code below assumes you have a property containing a UISearchController
instance within your UIViewController
subclass called searchController
override func viewWillDisappear(_ animated: Bool)
super.viewWillDisappear(animated)
if
animated
&& !searchController.isActive
&& !searchController.isEditing
&& navigationController.map($0.viewControllers.last != self) ?? false,
let searchBarSuperview = searchController.searchBar.superview,
let searchBarHeightConstraint = searchBarSuperview.constraints.first(where:
$0.firstAttribute == .height
&& $0.secondItem == nil
&& $0.secondAttribute == .notAnAttribute
&& $0.constant > 0
)
UIView.performWithoutAnimation
searchBarHeightConstraint.constant = 0
searchBarSuperview.superview?.layoutIfNeeded()
You can remove the performWithoutAnimation
and layoutIfNeeded
, and it will still animate; however I found the animation was never triggered the first time, and it doesn't look that great anyway.
I hope Apple fixes this in a later iOS release, the current release is 12.1.4 at the time of writing.
answered Mar 5 at 7:25
stustu
32636
32636
add a comment |
add a comment |
The accepted answer does solve the problem for some situations, but I was experiencing it resulting in the complete removal of the navigationItem
in the pushed view controller if the first search bar was active.
I've come up with another workaround, similar to the answer by stu, but requiring no meddling with constraints. The approach is to determine, at the point of the segue, whether the search bar is visible. If it is, we instruct the destination view controller to make its search bar visible from load. This means that the navigation item animation behaves correctly:
Assuming the two view controllers are called UIViewController1
and UIViewController2
, where 1
pushes 2
, the code is as follows:
class ViewController1: UITableViewController
override func viewDidLoad()
super.viewDidLoad()
let searchController = UISearchController(searchResultsController: nil)
searchController.obscuresBackgroundDuringPresentation = false
navigationItem.searchController = searchController
definesPresentationContext = true
override func prepare(for segue: UIStoryboardSegue, sender: Any?)
if let viewController2 = segue.destination as? ViewController2, let searchController = navigationItem.searchController
// If the search bar is visible (but not active, which would make it visible but at the top of the view)
// in this view controller as we are preparing to segue, instruct the destination view controller that its
// search bar should be visible from load.
viewController2.forceSearchBarVisibleOnLoad = !searchController.isActive && searchController.searchBar.frame.height > 0
class ViewController2: UITableViewController
var forceSearchBarVisibleOnLoad = false
override func viewDidLoad()
super.viewDidLoad()
let searchController = UISearchController(searchResultsController: nil)
searchController.obscuresBackgroundDuringPresentation = false
navigationItem.searchController = searchController
// If on load we want to force the search bar to be visible, we make it so that it is always visible to start with
if forceSearchBarVisibleOnLoad
navigationItem.hidesSearchBarWhenScrolling = false
override func viewDidAppear(_ animated: Bool)
super.viewDidAppear(animated)
// When the view has appeared, we switch back the default behaviour of the search bar being hideable.
// The search bar will already be visible at this point, thus achieving what we aimed to do (have it
// visible during the animation).
navigationItem.hidesSearchBarWhenScrolling = true
add a comment |
The accepted answer does solve the problem for some situations, but I was experiencing it resulting in the complete removal of the navigationItem
in the pushed view controller if the first search bar was active.
I've come up with another workaround, similar to the answer by stu, but requiring no meddling with constraints. The approach is to determine, at the point of the segue, whether the search bar is visible. If it is, we instruct the destination view controller to make its search bar visible from load. This means that the navigation item animation behaves correctly:
Assuming the two view controllers are called UIViewController1
and UIViewController2
, where 1
pushes 2
, the code is as follows:
class ViewController1: UITableViewController
override func viewDidLoad()
super.viewDidLoad()
let searchController = UISearchController(searchResultsController: nil)
searchController.obscuresBackgroundDuringPresentation = false
navigationItem.searchController = searchController
definesPresentationContext = true
override func prepare(for segue: UIStoryboardSegue, sender: Any?)
if let viewController2 = segue.destination as? ViewController2, let searchController = navigationItem.searchController
// If the search bar is visible (but not active, which would make it visible but at the top of the view)
// in this view controller as we are preparing to segue, instruct the destination view controller that its
// search bar should be visible from load.
viewController2.forceSearchBarVisibleOnLoad = !searchController.isActive && searchController.searchBar.frame.height > 0
class ViewController2: UITableViewController
var forceSearchBarVisibleOnLoad = false
override func viewDidLoad()
super.viewDidLoad()
let searchController = UISearchController(searchResultsController: nil)
searchController.obscuresBackgroundDuringPresentation = false
navigationItem.searchController = searchController
// If on load we want to force the search bar to be visible, we make it so that it is always visible to start with
if forceSearchBarVisibleOnLoad
navigationItem.hidesSearchBarWhenScrolling = false
override func viewDidAppear(_ animated: Bool)
super.viewDidAppear(animated)
// When the view has appeared, we switch back the default behaviour of the search bar being hideable.
// The search bar will already be visible at this point, thus achieving what we aimed to do (have it
// visible during the animation).
navigationItem.hidesSearchBarWhenScrolling = true
add a comment |
The accepted answer does solve the problem for some situations, but I was experiencing it resulting in the complete removal of the navigationItem
in the pushed view controller if the first search bar was active.
I've come up with another workaround, similar to the answer by stu, but requiring no meddling with constraints. The approach is to determine, at the point of the segue, whether the search bar is visible. If it is, we instruct the destination view controller to make its search bar visible from load. This means that the navigation item animation behaves correctly:
Assuming the two view controllers are called UIViewController1
and UIViewController2
, where 1
pushes 2
, the code is as follows:
class ViewController1: UITableViewController
override func viewDidLoad()
super.viewDidLoad()
let searchController = UISearchController(searchResultsController: nil)
searchController.obscuresBackgroundDuringPresentation = false
navigationItem.searchController = searchController
definesPresentationContext = true
override func prepare(for segue: UIStoryboardSegue, sender: Any?)
if let viewController2 = segue.destination as? ViewController2, let searchController = navigationItem.searchController
// If the search bar is visible (but not active, which would make it visible but at the top of the view)
// in this view controller as we are preparing to segue, instruct the destination view controller that its
// search bar should be visible from load.
viewController2.forceSearchBarVisibleOnLoad = !searchController.isActive && searchController.searchBar.frame.height > 0
class ViewController2: UITableViewController
var forceSearchBarVisibleOnLoad = false
override func viewDidLoad()
super.viewDidLoad()
let searchController = UISearchController(searchResultsController: nil)
searchController.obscuresBackgroundDuringPresentation = false
navigationItem.searchController = searchController
// If on load we want to force the search bar to be visible, we make it so that it is always visible to start with
if forceSearchBarVisibleOnLoad
navigationItem.hidesSearchBarWhenScrolling = false
override func viewDidAppear(_ animated: Bool)
super.viewDidAppear(animated)
// When the view has appeared, we switch back the default behaviour of the search bar being hideable.
// The search bar will already be visible at this point, thus achieving what we aimed to do (have it
// visible during the animation).
navigationItem.hidesSearchBarWhenScrolling = true
The accepted answer does solve the problem for some situations, but I was experiencing it resulting in the complete removal of the navigationItem
in the pushed view controller if the first search bar was active.
I've come up with another workaround, similar to the answer by stu, but requiring no meddling with constraints. The approach is to determine, at the point of the segue, whether the search bar is visible. If it is, we instruct the destination view controller to make its search bar visible from load. This means that the navigation item animation behaves correctly:
Assuming the two view controllers are called UIViewController1
and UIViewController2
, where 1
pushes 2
, the code is as follows:
class ViewController1: UITableViewController
override func viewDidLoad()
super.viewDidLoad()
let searchController = UISearchController(searchResultsController: nil)
searchController.obscuresBackgroundDuringPresentation = false
navigationItem.searchController = searchController
definesPresentationContext = true
override func prepare(for segue: UIStoryboardSegue, sender: Any?)
if let viewController2 = segue.destination as? ViewController2, let searchController = navigationItem.searchController
// If the search bar is visible (but not active, which would make it visible but at the top of the view)
// in this view controller as we are preparing to segue, instruct the destination view controller that its
// search bar should be visible from load.
viewController2.forceSearchBarVisibleOnLoad = !searchController.isActive && searchController.searchBar.frame.height > 0
class ViewController2: UITableViewController
var forceSearchBarVisibleOnLoad = false
override func viewDidLoad()
super.viewDidLoad()
let searchController = UISearchController(searchResultsController: nil)
searchController.obscuresBackgroundDuringPresentation = false
navigationItem.searchController = searchController
// If on load we want to force the search bar to be visible, we make it so that it is always visible to start with
if forceSearchBarVisibleOnLoad
navigationItem.hidesSearchBarWhenScrolling = false
override func viewDidAppear(_ animated: Bool)
super.viewDidAppear(animated)
// When the view has appeared, we switch back the default behaviour of the search bar being hideable.
// The search bar will already be visible at this point, thus achieving what we aimed to do (have it
// visible during the animation).
navigationItem.hidesSearchBarWhenScrolling = true
answered Mar 7 at 12:26
Andrew BennetAndrew Bennet
75611134
75611134
add a comment |
add a comment |
I have added this code in viewDidLoad() and it's working, when I moved in b/w of tabs
searchController.dimsBackgroundDuringPresentation
2
How can this change something? Did you forget appending= false
in your line of code?
– fl034
Oct 11 '18 at 8:31
add a comment |
I have added this code in viewDidLoad() and it's working, when I moved in b/w of tabs
searchController.dimsBackgroundDuringPresentation
2
How can this change something? Did you forget appending= false
in your line of code?
– fl034
Oct 11 '18 at 8:31
add a comment |
I have added this code in viewDidLoad() and it's working, when I moved in b/w of tabs
searchController.dimsBackgroundDuringPresentation
I have added this code in viewDidLoad() and it's working, when I moved in b/w of tabs
searchController.dimsBackgroundDuringPresentation
answered Jul 17 '18 at 17:50
shiju86.vshiju86.v
491310
491310
2
How can this change something? Did you forget appending= false
in your line of code?
– fl034
Oct 11 '18 at 8:31
add a comment |
2
How can this change something? Did you forget appending= false
in your line of code?
– fl034
Oct 11 '18 at 8:31
2
2
How can this change something? Did you forget appending
= false
in your line of code?– fl034
Oct 11 '18 at 8:31
How can this change something? Did you forget appending
= false
in your line of code?– fl034
Oct 11 '18 at 8:31
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f46301813%2fbroken-uisearchbar-animation-embedded-in-navigationitem%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Check in device.. It may be simulator issue. Try with
viewDidLoad()
(instead of loadView() )– Krunal
Sep 19 '17 at 13:47
Nope, on device it is the same.
– BartoszCichecki
Sep 19 '17 at 13:49
And viewDidLoad has the same result.
– BartoszCichecki
Sep 19 '17 at 13:49