Swift: searchBar still visible with navigationItem.hidesSearchBarWhenScrolling = true
In Swift I'm trying to achieve a hidden searchBar
, which becomes visible when scrolling,
I'm using this
navigationItem.searchController = searchController
navigationItem.hidesSearchBarWhenScrolling = true
I've tried moving the above code around, but regardless the searchBar
is visible no matter where this is called in the ViewController
file.
is there something that could be overriding
this functionality?
the only other code in the file where I reference the searchBar
or searchController
is the following:
if self.searchController.isActive && searchController.searchBar.text != "" {...
self.searchController.searchBar.placeholder = "Search (title)"
func updateSearchResults(for searchController: UISearchController) {
if let searchText = searchController.searchBar.text, !searchText.isEmpty {
filteredArr = defaultArr.filter {...
func configureSearchController () {
//Setup the Search Controller
searchController.searchResultsUpdater = self
searchController.hidesNavigationBarDuringPresentation = true
searchController.dimsBackgroundDuringPresentation = false
searchController.searchBar.searchBarStyle = .minimal
searchController.definesPresentationContext = true
navigationItem.searchController = searchController
navigationItem.hidesSearchBarWhenScrolling = true
}
// I call reloadData a few times throughout as well
tableView.reloadData()
I'm not sure how any of the above could effect hideSearchBarWhenScrolling = true
.
I'm so confused how this is happening, does anyone have any advice?
Any help would be much appreciated.
swift visible searchbar swift4.2
add a comment |
In Swift I'm trying to achieve a hidden searchBar
, which becomes visible when scrolling,
I'm using this
navigationItem.searchController = searchController
navigationItem.hidesSearchBarWhenScrolling = true
I've tried moving the above code around, but regardless the searchBar
is visible no matter where this is called in the ViewController
file.
is there something that could be overriding
this functionality?
the only other code in the file where I reference the searchBar
or searchController
is the following:
if self.searchController.isActive && searchController.searchBar.text != "" {...
self.searchController.searchBar.placeholder = "Search (title)"
func updateSearchResults(for searchController: UISearchController) {
if let searchText = searchController.searchBar.text, !searchText.isEmpty {
filteredArr = defaultArr.filter {...
func configureSearchController () {
//Setup the Search Controller
searchController.searchResultsUpdater = self
searchController.hidesNavigationBarDuringPresentation = true
searchController.dimsBackgroundDuringPresentation = false
searchController.searchBar.searchBarStyle = .minimal
searchController.definesPresentationContext = true
navigationItem.searchController = searchController
navigationItem.hidesSearchBarWhenScrolling = true
}
// I call reloadData a few times throughout as well
tableView.reloadData()
I'm not sure how any of the above could effect hideSearchBarWhenScrolling = true
.
I'm so confused how this is happening, does anyone have any advice?
Any help would be much appreciated.
swift visible searchbar swift4.2
could you please add screenshot of screen?
– iVarun
Dec 29 '18 at 6:02
I've edited with a gif showing the behaviour
– clomas
Dec 29 '18 at 6:12
Could you please try with 20-25 rows inUITableView
?
– iVarun
Dec 29 '18 at 6:16
regardless of how many items are in theUITableView
theUIsearchBar
is still static and remains visible. I tried with 20-25, 50 etc.
– clomas
Dec 29 '18 at 7:35
A label which was "behind" the tableView was causing the issue: searchBar always visible: imgur.com/lXulqjb searchBar hidden as intended: imgur.com/4YmlRbK
– clomas
Jan 5 at 3:07
add a comment |
In Swift I'm trying to achieve a hidden searchBar
, which becomes visible when scrolling,
I'm using this
navigationItem.searchController = searchController
navigationItem.hidesSearchBarWhenScrolling = true
I've tried moving the above code around, but regardless the searchBar
is visible no matter where this is called in the ViewController
file.
is there something that could be overriding
this functionality?
the only other code in the file where I reference the searchBar
or searchController
is the following:
if self.searchController.isActive && searchController.searchBar.text != "" {...
self.searchController.searchBar.placeholder = "Search (title)"
func updateSearchResults(for searchController: UISearchController) {
if let searchText = searchController.searchBar.text, !searchText.isEmpty {
filteredArr = defaultArr.filter {...
func configureSearchController () {
//Setup the Search Controller
searchController.searchResultsUpdater = self
searchController.hidesNavigationBarDuringPresentation = true
searchController.dimsBackgroundDuringPresentation = false
searchController.searchBar.searchBarStyle = .minimal
searchController.definesPresentationContext = true
navigationItem.searchController = searchController
navigationItem.hidesSearchBarWhenScrolling = true
}
// I call reloadData a few times throughout as well
tableView.reloadData()
I'm not sure how any of the above could effect hideSearchBarWhenScrolling = true
.
I'm so confused how this is happening, does anyone have any advice?
Any help would be much appreciated.
swift visible searchbar swift4.2
In Swift I'm trying to achieve a hidden searchBar
, which becomes visible when scrolling,
I'm using this
navigationItem.searchController = searchController
navigationItem.hidesSearchBarWhenScrolling = true
I've tried moving the above code around, but regardless the searchBar
is visible no matter where this is called in the ViewController
file.
is there something that could be overriding
this functionality?
the only other code in the file where I reference the searchBar
or searchController
is the following:
if self.searchController.isActive && searchController.searchBar.text != "" {...
self.searchController.searchBar.placeholder = "Search (title)"
func updateSearchResults(for searchController: UISearchController) {
if let searchText = searchController.searchBar.text, !searchText.isEmpty {
filteredArr = defaultArr.filter {...
func configureSearchController () {
//Setup the Search Controller
searchController.searchResultsUpdater = self
searchController.hidesNavigationBarDuringPresentation = true
searchController.dimsBackgroundDuringPresentation = false
searchController.searchBar.searchBarStyle = .minimal
searchController.definesPresentationContext = true
navigationItem.searchController = searchController
navigationItem.hidesSearchBarWhenScrolling = true
}
// I call reloadData a few times throughout as well
tableView.reloadData()
I'm not sure how any of the above could effect hideSearchBarWhenScrolling = true
.
I'm so confused how this is happening, does anyone have any advice?
Any help would be much appreciated.
swift visible searchbar swift4.2
swift visible searchbar swift4.2
edited Dec 29 '18 at 6:12
clomas
asked Dec 29 '18 at 5:57
clomasclomas
115
115
could you please add screenshot of screen?
– iVarun
Dec 29 '18 at 6:02
I've edited with a gif showing the behaviour
– clomas
Dec 29 '18 at 6:12
Could you please try with 20-25 rows inUITableView
?
– iVarun
Dec 29 '18 at 6:16
regardless of how many items are in theUITableView
theUIsearchBar
is still static and remains visible. I tried with 20-25, 50 etc.
– clomas
Dec 29 '18 at 7:35
A label which was "behind" the tableView was causing the issue: searchBar always visible: imgur.com/lXulqjb searchBar hidden as intended: imgur.com/4YmlRbK
– clomas
Jan 5 at 3:07
add a comment |
could you please add screenshot of screen?
– iVarun
Dec 29 '18 at 6:02
I've edited with a gif showing the behaviour
– clomas
Dec 29 '18 at 6:12
Could you please try with 20-25 rows inUITableView
?
– iVarun
Dec 29 '18 at 6:16
regardless of how many items are in theUITableView
theUIsearchBar
is still static and remains visible. I tried with 20-25, 50 etc.
– clomas
Dec 29 '18 at 7:35
A label which was "behind" the tableView was causing the issue: searchBar always visible: imgur.com/lXulqjb searchBar hidden as intended: imgur.com/4YmlRbK
– clomas
Jan 5 at 3:07
could you please add screenshot of screen?
– iVarun
Dec 29 '18 at 6:02
could you please add screenshot of screen?
– iVarun
Dec 29 '18 at 6:02
I've edited with a gif showing the behaviour
– clomas
Dec 29 '18 at 6:12
I've edited with a gif showing the behaviour
– clomas
Dec 29 '18 at 6:12
Could you please try with 20-25 rows in
UITableView
?– iVarun
Dec 29 '18 at 6:16
Could you please try with 20-25 rows in
UITableView
?– iVarun
Dec 29 '18 at 6:16
regardless of how many items are in the
UITableView
the UIsearchBar
is still static and remains visible. I tried with 20-25, 50 etc.– clomas
Dec 29 '18 at 7:35
regardless of how many items are in the
UITableView
the UIsearchBar
is still static and remains visible. I tried with 20-25, 50 etc.– clomas
Dec 29 '18 at 7:35
A label which was "behind" the tableView was causing the issue: searchBar always visible: imgur.com/lXulqjb searchBar hidden as intended: imgur.com/4YmlRbK
– clomas
Jan 5 at 3:07
A label which was "behind" the tableView was causing the issue: searchBar always visible: imgur.com/lXulqjb searchBar hidden as intended: imgur.com/4YmlRbK
– clomas
Jan 5 at 3:07
add a comment |
1 Answer
1
active
oldest
votes
A label which was "behind" the tableView was causing the issue:
searchBar always visible:
searchBar hidden as intended:
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%2f53967096%2fswift-searchbar-still-visible-with-navigationitem-hidessearchbarwhenscrolling%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
A label which was "behind" the tableView was causing the issue:
searchBar always visible:
searchBar hidden as intended:
add a comment |
A label which was "behind" the tableView was causing the issue:
searchBar always visible:
searchBar hidden as intended:
add a comment |
A label which was "behind" the tableView was causing the issue:
searchBar always visible:
searchBar hidden as intended:
A label which was "behind" the tableView was causing the issue:
searchBar always visible:
searchBar hidden as intended:
answered Jan 5 at 3:14
clomasclomas
115
115
add a comment |
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%2f53967096%2fswift-searchbar-still-visible-with-navigationitem-hidessearchbarwhenscrolling%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
could you please add screenshot of screen?
– iVarun
Dec 29 '18 at 6:02
I've edited with a gif showing the behaviour
– clomas
Dec 29 '18 at 6:12
Could you please try with 20-25 rows in
UITableView
?– iVarun
Dec 29 '18 at 6:16
regardless of how many items are in the
UITableView
theUIsearchBar
is still static and remains visible. I tried with 20-25, 50 etc.– clomas
Dec 29 '18 at 7:35
A label which was "behind" the tableView was causing the issue: searchBar always visible: imgur.com/lXulqjb searchBar hidden as intended: imgur.com/4YmlRbK
– clomas
Jan 5 at 3:07