UISearchController's UISearchBar shifts incorrectly and jumps when UITableView is scrolled
up vote
1
down vote
favorite
In the video, it's a little difficult to see what's going on, so I'll try to explain it.
https://youtu.be/yOrCJB9yZlg
I have UIViewController
with UITableView
inside its root view. Binded via Autolayout
(there is no difference how it's binded: to SuperView or to SafeArea).
SearchBar added like this:
let search = UISearchController(searchResultsController: nil)
self.navigationItem.searchController = search
When I slowly scroll table, the transition between large navbar and compact navbar, and then animation of showing in and out of searchBar is too fast. Searchbar jumping in/out of navbar instead of smoothly opened/closed; navbar transitioning is jumping between two states, large and compact, without smoothly passes through the middle half-opened state while you slowly moving your finger on screen, like in system apps (Mail, Phone, Messages, Contacts etc).
I made the example from an empty project to demonstrate the issue; there isn't any changes to navigation bar logic, or any logic at all. Just two new VC's and this odd behaviour.
If i create xCode's "Master-Details" project example and add UISearchController
to it, it will work properly. I assume its because they used UITableViewController
instead of UIViewController
+ UITableView
inside.
What the reason of this behaviour and how to fix it?
ios swift uinavigationbar uisearchbar uisearchcontroller
add a comment |
up vote
1
down vote
favorite
In the video, it's a little difficult to see what's going on, so I'll try to explain it.
https://youtu.be/yOrCJB9yZlg
I have UIViewController
with UITableView
inside its root view. Binded via Autolayout
(there is no difference how it's binded: to SuperView or to SafeArea).
SearchBar added like this:
let search = UISearchController(searchResultsController: nil)
self.navigationItem.searchController = search
When I slowly scroll table, the transition between large navbar and compact navbar, and then animation of showing in and out of searchBar is too fast. Searchbar jumping in/out of navbar instead of smoothly opened/closed; navbar transitioning is jumping between two states, large and compact, without smoothly passes through the middle half-opened state while you slowly moving your finger on screen, like in system apps (Mail, Phone, Messages, Contacts etc).
I made the example from an empty project to demonstrate the issue; there isn't any changes to navigation bar logic, or any logic at all. Just two new VC's and this odd behaviour.
If i create xCode's "Master-Details" project example and add UISearchController
to it, it will work properly. I assume its because they used UITableViewController
instead of UIViewController
+ UITableView
inside.
What the reason of this behaviour and how to fix it?
ios swift uinavigationbar uisearchbar uisearchcontroller
your question is a bit confusing. Is your problem the searching closing/opening too quickly rather than being smooth like in the system apps?
– Manju Basha
Nov 19 at 14:00
Yes, exactly. I don't know how to explain it clearly.
– surfrider
Nov 19 at 14:03
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
In the video, it's a little difficult to see what's going on, so I'll try to explain it.
https://youtu.be/yOrCJB9yZlg
I have UIViewController
with UITableView
inside its root view. Binded via Autolayout
(there is no difference how it's binded: to SuperView or to SafeArea).
SearchBar added like this:
let search = UISearchController(searchResultsController: nil)
self.navigationItem.searchController = search
When I slowly scroll table, the transition between large navbar and compact navbar, and then animation of showing in and out of searchBar is too fast. Searchbar jumping in/out of navbar instead of smoothly opened/closed; navbar transitioning is jumping between two states, large and compact, without smoothly passes through the middle half-opened state while you slowly moving your finger on screen, like in system apps (Mail, Phone, Messages, Contacts etc).
I made the example from an empty project to demonstrate the issue; there isn't any changes to navigation bar logic, or any logic at all. Just two new VC's and this odd behaviour.
If i create xCode's "Master-Details" project example and add UISearchController
to it, it will work properly. I assume its because they used UITableViewController
instead of UIViewController
+ UITableView
inside.
What the reason of this behaviour and how to fix it?
ios swift uinavigationbar uisearchbar uisearchcontroller
In the video, it's a little difficult to see what's going on, so I'll try to explain it.
https://youtu.be/yOrCJB9yZlg
I have UIViewController
with UITableView
inside its root view. Binded via Autolayout
(there is no difference how it's binded: to SuperView or to SafeArea).
SearchBar added like this:
let search = UISearchController(searchResultsController: nil)
self.navigationItem.searchController = search
When I slowly scroll table, the transition between large navbar and compact navbar, and then animation of showing in and out of searchBar is too fast. Searchbar jumping in/out of navbar instead of smoothly opened/closed; navbar transitioning is jumping between two states, large and compact, without smoothly passes through the middle half-opened state while you slowly moving your finger on screen, like in system apps (Mail, Phone, Messages, Contacts etc).
I made the example from an empty project to demonstrate the issue; there isn't any changes to navigation bar logic, or any logic at all. Just two new VC's and this odd behaviour.
If i create xCode's "Master-Details" project example and add UISearchController
to it, it will work properly. I assume its because they used UITableViewController
instead of UIViewController
+ UITableView
inside.
What the reason of this behaviour and how to fix it?
ios swift uinavigationbar uisearchbar uisearchcontroller
ios swift uinavigationbar uisearchbar uisearchcontroller
edited Nov 19 at 14:42
Damon
480317
480317
asked Nov 19 at 13:23
surfrider
757820
757820
your question is a bit confusing. Is your problem the searching closing/opening too quickly rather than being smooth like in the system apps?
– Manju Basha
Nov 19 at 14:00
Yes, exactly. I don't know how to explain it clearly.
– surfrider
Nov 19 at 14:03
add a comment |
your question is a bit confusing. Is your problem the searching closing/opening too quickly rather than being smooth like in the system apps?
– Manju Basha
Nov 19 at 14:00
Yes, exactly. I don't know how to explain it clearly.
– surfrider
Nov 19 at 14:03
your question is a bit confusing. Is your problem the searching closing/opening too quickly rather than being smooth like in the system apps?
– Manju Basha
Nov 19 at 14:00
your question is a bit confusing. Is your problem the searching closing/opening too quickly rather than being smooth like in the system apps?
– Manju Basha
Nov 19 at 14:00
Yes, exactly. I don't know how to explain it clearly.
– surfrider
Nov 19 at 14:03
Yes, exactly. I don't know how to explain it clearly.
– surfrider
Nov 19 at 14:03
add a comment |
2 Answers
2
active
oldest
votes
up vote
1
down vote
accepted
What you have done is correct. Did you try running your code in a device? Feels more like a glitch in the simulator. I tried what you tried and it works fine for me in the device. Whereas the glitch occurs in simulator.
Refer to this article. They have explained step by step process.
I can confirm that creationUITableView
from code and inserting it inUIViewController
solved my issue in the example. But I also had to create theUINavigationController
manually from code (inAppDelegate
createUIWindow
, thenUINavigationViewController
with my ViewController as root). Otherway it didn't work. Very strange behaviour with IB. xCode's bug?
– surfrider
Nov 19 at 16:15
Thank you! By the way, a creation of all the stuff from IB is working with these settings from answer stackoverflow.com/a/50171002/667483
– surfrider
Nov 19 at 16:44
add a comment |
up vote
1
down vote
This is a known problem and your code seems fine. This problem was already discussed here.
Problem appears when you're using UIScrollView
or its subclasses with large navigation titles. It doesn't work. Problem disappears when you use UICollectionViewController
or UITableViewController
instead.
1
Thanks! This thread is also very helpful. This stackoverflow.com/a/50171002/667483 solved all the problems even if using IB. I don't know which of answers is most correct, they both solved my problem in different ways. I give the vote to Manju Basha for reputation boost! :)
– surfrider
Nov 19 at 16:44
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
What you have done is correct. Did you try running your code in a device? Feels more like a glitch in the simulator. I tried what you tried and it works fine for me in the device. Whereas the glitch occurs in simulator.
Refer to this article. They have explained step by step process.
I can confirm that creationUITableView
from code and inserting it inUIViewController
solved my issue in the example. But I also had to create theUINavigationController
manually from code (inAppDelegate
createUIWindow
, thenUINavigationViewController
with my ViewController as root). Otherway it didn't work. Very strange behaviour with IB. xCode's bug?
– surfrider
Nov 19 at 16:15
Thank you! By the way, a creation of all the stuff from IB is working with these settings from answer stackoverflow.com/a/50171002/667483
– surfrider
Nov 19 at 16:44
add a comment |
up vote
1
down vote
accepted
What you have done is correct. Did you try running your code in a device? Feels more like a glitch in the simulator. I tried what you tried and it works fine for me in the device. Whereas the glitch occurs in simulator.
Refer to this article. They have explained step by step process.
I can confirm that creationUITableView
from code and inserting it inUIViewController
solved my issue in the example. But I also had to create theUINavigationController
manually from code (inAppDelegate
createUIWindow
, thenUINavigationViewController
with my ViewController as root). Otherway it didn't work. Very strange behaviour with IB. xCode's bug?
– surfrider
Nov 19 at 16:15
Thank you! By the way, a creation of all the stuff from IB is working with these settings from answer stackoverflow.com/a/50171002/667483
– surfrider
Nov 19 at 16:44
add a comment |
up vote
1
down vote
accepted
up vote
1
down vote
accepted
What you have done is correct. Did you try running your code in a device? Feels more like a glitch in the simulator. I tried what you tried and it works fine for me in the device. Whereas the glitch occurs in simulator.
Refer to this article. They have explained step by step process.
What you have done is correct. Did you try running your code in a device? Feels more like a glitch in the simulator. I tried what you tried and it works fine for me in the device. Whereas the glitch occurs in simulator.
Refer to this article. They have explained step by step process.
answered Nov 19 at 15:00
Manju Basha
302319
302319
I can confirm that creationUITableView
from code and inserting it inUIViewController
solved my issue in the example. But I also had to create theUINavigationController
manually from code (inAppDelegate
createUIWindow
, thenUINavigationViewController
with my ViewController as root). Otherway it didn't work. Very strange behaviour with IB. xCode's bug?
– surfrider
Nov 19 at 16:15
Thank you! By the way, a creation of all the stuff from IB is working with these settings from answer stackoverflow.com/a/50171002/667483
– surfrider
Nov 19 at 16:44
add a comment |
I can confirm that creationUITableView
from code and inserting it inUIViewController
solved my issue in the example. But I also had to create theUINavigationController
manually from code (inAppDelegate
createUIWindow
, thenUINavigationViewController
with my ViewController as root). Otherway it didn't work. Very strange behaviour with IB. xCode's bug?
– surfrider
Nov 19 at 16:15
Thank you! By the way, a creation of all the stuff from IB is working with these settings from answer stackoverflow.com/a/50171002/667483
– surfrider
Nov 19 at 16:44
I can confirm that creation
UITableView
from code and inserting it in UIViewController
solved my issue in the example. But I also had to create the UINavigationController
manually from code (in AppDelegate
create UIWindow
, then UINavigationViewController
with my ViewController as root). Otherway it didn't work. Very strange behaviour with IB. xCode's bug?– surfrider
Nov 19 at 16:15
I can confirm that creation
UITableView
from code and inserting it in UIViewController
solved my issue in the example. But I also had to create the UINavigationController
manually from code (in AppDelegate
create UIWindow
, then UINavigationViewController
with my ViewController as root). Otherway it didn't work. Very strange behaviour with IB. xCode's bug?– surfrider
Nov 19 at 16:15
Thank you! By the way, a creation of all the stuff from IB is working with these settings from answer stackoverflow.com/a/50171002/667483
– surfrider
Nov 19 at 16:44
Thank you! By the way, a creation of all the stuff from IB is working with these settings from answer stackoverflow.com/a/50171002/667483
– surfrider
Nov 19 at 16:44
add a comment |
up vote
1
down vote
This is a known problem and your code seems fine. This problem was already discussed here.
Problem appears when you're using UIScrollView
or its subclasses with large navigation titles. It doesn't work. Problem disappears when you use UICollectionViewController
or UITableViewController
instead.
1
Thanks! This thread is also very helpful. This stackoverflow.com/a/50171002/667483 solved all the problems even if using IB. I don't know which of answers is most correct, they both solved my problem in different ways. I give the vote to Manju Basha for reputation boost! :)
– surfrider
Nov 19 at 16:44
add a comment |
up vote
1
down vote
This is a known problem and your code seems fine. This problem was already discussed here.
Problem appears when you're using UIScrollView
or its subclasses with large navigation titles. It doesn't work. Problem disappears when you use UICollectionViewController
or UITableViewController
instead.
1
Thanks! This thread is also very helpful. This stackoverflow.com/a/50171002/667483 solved all the problems even if using IB. I don't know which of answers is most correct, they both solved my problem in different ways. I give the vote to Manju Basha for reputation boost! :)
– surfrider
Nov 19 at 16:44
add a comment |
up vote
1
down vote
up vote
1
down vote
This is a known problem and your code seems fine. This problem was already discussed here.
Problem appears when you're using UIScrollView
or its subclasses with large navigation titles. It doesn't work. Problem disappears when you use UICollectionViewController
or UITableViewController
instead.
This is a known problem and your code seems fine. This problem was already discussed here.
Problem appears when you're using UIScrollView
or its subclasses with large navigation titles. It doesn't work. Problem disappears when you use UICollectionViewController
or UITableViewController
instead.
answered Nov 19 at 15:05
fewlinesofcode
1,894515
1,894515
1
Thanks! This thread is also very helpful. This stackoverflow.com/a/50171002/667483 solved all the problems even if using IB. I don't know which of answers is most correct, they both solved my problem in different ways. I give the vote to Manju Basha for reputation boost! :)
– surfrider
Nov 19 at 16:44
add a comment |
1
Thanks! This thread is also very helpful. This stackoverflow.com/a/50171002/667483 solved all the problems even if using IB. I don't know which of answers is most correct, they both solved my problem in different ways. I give the vote to Manju Basha for reputation boost! :)
– surfrider
Nov 19 at 16:44
1
1
Thanks! This thread is also very helpful. This stackoverflow.com/a/50171002/667483 solved all the problems even if using IB. I don't know which of answers is most correct, they both solved my problem in different ways. I give the vote to Manju Basha for reputation boost! :)
– surfrider
Nov 19 at 16:44
Thanks! This thread is also very helpful. This stackoverflow.com/a/50171002/667483 solved all the problems even if using IB. I don't know which of answers is most correct, they both solved my problem in different ways. I give the vote to Manju Basha for reputation boost! :)
– surfrider
Nov 19 at 16:44
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.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- 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%2f53375589%2fuisearchcontrollers-uisearchbar-shifts-incorrectly-and-jumps-when-uitableview-i%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
your question is a bit confusing. Is your problem the searching closing/opening too quickly rather than being smooth like in the system apps?
– Manju Basha
Nov 19 at 14:00
Yes, exactly. I don't know how to explain it clearly.
– surfrider
Nov 19 at 14:03