Searchbar cancel button text is truncated
up vote
1
down vote
favorite
Having various problems setting up the UISearchBar to work properly. It should be shown in the navigationBar. Using the "old" way setting navigationItem.titleView = searchController.searchBar
. As seen on the picture below, the Cancel button text is truncated. Any ideas how to solve this problem? I have tried to set searchController.searchBar.sizeToFit()
with no luck.
fileprivate lazy var searchController: UISearchController = {
let sc = UISearchController(searchResultsController: nil)
sc.delegate = self
sc.searchBar.delegate = self
sc.searchBar.returnKeyType = .done
sc.searchBar.tintColor = UIColor.black
sc.searchResultsUpdater = self
sc.hidesNavigationBarDuringPresentation = false
sc.dimsBackgroundDuringPresentation = false
return sc
} ()
swift uisearchbar ios11 uisearchcontroller
add a comment |
up vote
1
down vote
favorite
Having various problems setting up the UISearchBar to work properly. It should be shown in the navigationBar. Using the "old" way setting navigationItem.titleView = searchController.searchBar
. As seen on the picture below, the Cancel button text is truncated. Any ideas how to solve this problem? I have tried to set searchController.searchBar.sizeToFit()
with no luck.
fileprivate lazy var searchController: UISearchController = {
let sc = UISearchController(searchResultsController: nil)
sc.delegate = self
sc.searchBar.delegate = self
sc.searchBar.returnKeyType = .done
sc.searchBar.tintColor = UIColor.black
sc.searchResultsUpdater = self
sc.hidesNavigationBarDuringPresentation = false
sc.dimsBackgroundDuringPresentation = false
return sc
} ()
swift uisearchbar ios11 uisearchcontroller
how do you add it to the navigation bar?
– Scriptable
Nov 8 at 11:22
I'm usingnavigationItem.titleView = searchController.searchBar
– Dan
Nov 8 at 12:02
try if #available(iOS 11.0, *) { navigationItem.searchController = searchController } else { navigationItem.titleView = searchController.searchBar searchController.searchBar.sizeToFit() }
– Scriptable
Nov 8 at 12:40
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
Having various problems setting up the UISearchBar to work properly. It should be shown in the navigationBar. Using the "old" way setting navigationItem.titleView = searchController.searchBar
. As seen on the picture below, the Cancel button text is truncated. Any ideas how to solve this problem? I have tried to set searchController.searchBar.sizeToFit()
with no luck.
fileprivate lazy var searchController: UISearchController = {
let sc = UISearchController(searchResultsController: nil)
sc.delegate = self
sc.searchBar.delegate = self
sc.searchBar.returnKeyType = .done
sc.searchBar.tintColor = UIColor.black
sc.searchResultsUpdater = self
sc.hidesNavigationBarDuringPresentation = false
sc.dimsBackgroundDuringPresentation = false
return sc
} ()
swift uisearchbar ios11 uisearchcontroller
Having various problems setting up the UISearchBar to work properly. It should be shown in the navigationBar. Using the "old" way setting navigationItem.titleView = searchController.searchBar
. As seen on the picture below, the Cancel button text is truncated. Any ideas how to solve this problem? I have tried to set searchController.searchBar.sizeToFit()
with no luck.
fileprivate lazy var searchController: UISearchController = {
let sc = UISearchController(searchResultsController: nil)
sc.delegate = self
sc.searchBar.delegate = self
sc.searchBar.returnKeyType = .done
sc.searchBar.tintColor = UIColor.black
sc.searchResultsUpdater = self
sc.hidesNavigationBarDuringPresentation = false
sc.dimsBackgroundDuringPresentation = false
return sc
} ()
swift uisearchbar ios11 uisearchcontroller
swift uisearchbar ios11 uisearchcontroller
asked Nov 8 at 10:34
Dan
6719
6719
how do you add it to the navigation bar?
– Scriptable
Nov 8 at 11:22
I'm usingnavigationItem.titleView = searchController.searchBar
– Dan
Nov 8 at 12:02
try if #available(iOS 11.0, *) { navigationItem.searchController = searchController } else { navigationItem.titleView = searchController.searchBar searchController.searchBar.sizeToFit() }
– Scriptable
Nov 8 at 12:40
add a comment |
how do you add it to the navigation bar?
– Scriptable
Nov 8 at 11:22
I'm usingnavigationItem.titleView = searchController.searchBar
– Dan
Nov 8 at 12:02
try if #available(iOS 11.0, *) { navigationItem.searchController = searchController } else { navigationItem.titleView = searchController.searchBar searchController.searchBar.sizeToFit() }
– Scriptable
Nov 8 at 12:40
how do you add it to the navigation bar?
– Scriptable
Nov 8 at 11:22
how do you add it to the navigation bar?
– Scriptable
Nov 8 at 11:22
I'm using
navigationItem.titleView = searchController.searchBar
– Dan
Nov 8 at 12:02
I'm using
navigationItem.titleView = searchController.searchBar
– Dan
Nov 8 at 12:02
try if #available(iOS 11.0, *) { navigationItem.searchController = searchController } else { navigationItem.titleView = searchController.searchBar searchController.searchBar.sizeToFit() }
– Scriptable
Nov 8 at 12:40
try if #available(iOS 11.0, *) { navigationItem.searchController = searchController } else { navigationItem.titleView = searchController.searchBar searchController.searchBar.sizeToFit() }
– Scriptable
Nov 8 at 12:40
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
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%2f53205927%2fsearchbar-cancel-button-text-is-truncated%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
how do you add it to the navigation bar?
– Scriptable
Nov 8 at 11:22
I'm using
navigationItem.titleView = searchController.searchBar
– Dan
Nov 8 at 12:02
try if #available(iOS 11.0, *) { navigationItem.searchController = searchController } else { navigationItem.titleView = searchController.searchBar searchController.searchBar.sizeToFit() }
– Scriptable
Nov 8 at 12:40