So... We have UITableView. If we add UISearchBar to the top of UITableView than we will have search bar, that can be hidden by scrolling our table (even if table is empty) and it's working out of box
I'd like to add UIView instead of Search bar and have the same behavior. The questions is how it's working? What method/property does that?
In your viewWillAppear: method add just self.tableView.contentOffset = CGPointMake(0, myView.frame.size.height);
this is not an easy subject. You should create a UIScrollView and inside it your view (at the top) and your tableView. But a tableView is another ScrollView (ScrollView is the father than tableView), and you need switch between them in order one receive the drag event or the other. In all WWDC Videos, there is a video about scrollView, in the last you can find one than explain how to do this.
Related
I've have been trying for a while now, to implement a specific behavior in my app. On the initial view of my app, there must be a logo(imageView), a label and a textField. It should be possible to scroll down from the initial view, to a tableView. while the user scrolls down, the label in moved up in the window, to form a search field for the tableView. Then the scrollView should lock to the part with the tableView, and it should only be possible to scroll back up, if dragging elsewhere than the tableView.
What is best practice for doing as described?
The image show (only for illustration, i havn't been using story board when trying to implement it) an overview of the problem:
The way I've tried to do this so far, is by embedding the tableView in a scrollView (as seen on image), enabling paging on the scrollView, and than disabling scrolling on the scrollView, when the buttom part has been reached. I've added a gesture reconizer on the part with of the screen with the textField.
These two posts (Scrollview with embedded tableview and Use Pan Recognizer to Control ScrollView) descripe i further detail what i've tried so far.
But the question is more to, is there an alternate solution for making behaviour descriped above?
Maybe interactive animated transitioning between view controllers somehow?
YES there are! Implement a table view with a header view. And remove the scroll view.
self.tableView.tableHeaderView = topView
where topView will be the view wish as the UIImage, the label and textField
I have a UITableView within my UIViewController.
I want the table to scroll to the top when the status bar is pressed. i've tried self.tableView.scrollsToTop = YES but it does not scroll the table to the top.
Any idea on how to make this work?
Looking at the documentation for UIScrollView, scrolls to top, there is a special consideration: "on iPhone, the scroll-to-top gesture has no effect if there is more than one scroll view on-screen that has scrollsToTop set to yes."
This could be part of the issue, without seeing your actual code.
Another technique you might employ since it sounds like a uitableview nested inside a view controller, is to call scrollToRowAtIndexPath:atScrollPosition:animated:
So, detect when status bar is pressed, then call [YourTable scrollToRowAtIndexPath:probably0 atScrollPosition: UITableViewScrollPositionTop animated:YES/NO];
I have a UIScrollView that contains some UITableViews. Now if I tap the status bar of my phone, the usual behavior would be that the visible tableView would scroll to the top. As it's contained in my scrollView, it's not doing that.
Neither the scrollView nor the tableView get any callbacks from the system. I was hoping the scrollViewShouldScrollToTop: would be called on my containing scrollView so that I can trigger that behavior on my tableViews myself, but it's not.
Any ideas? Thanks for any hints!
When you have a scrollview that contains another scrollview none of them will get the scrollToTop event. You got to set one of the scrollviews to scrollsToTop = No in order for the other one to work.
I've created a view with a UIScrollView, it has height 1000px. I've added a UITableView to the view, plus other labels and buttons. When I launch it, everything is in its place except the table. Can anyone fix my problem?
I've tried:
table.hidden = NO;
and
[scrollView addSubview:table];
but nothing happened.
The documentation for UIScrollView specifically says not to do this:
Important: You should not embed UIWebView or UITableView objects in UIScrollView objects. If you do so, unexpected behavior can result because touch events for the two objects can be mixed up and wrongly handled.
I would suggest adding the other views you intend to put into the scroll view into the table as a tableHeaderView, tableFooterView, or as custom cells.
This should be a fairly general question, but I have a view in which I placed a UITableView and implemented it properly. It works well and it scrolls. But I want to add a UISearchBar attached to it so that it will scroll along with the table. But when I add the search bar onto the tableview it shows up, but the tableview will not scroll anymore. I don't actually need any input into the search bar, and I disabled user interaction. Is there any way to add the search bar (no need to implement it) and have it scroll?
(I will rate up anyone who answers!)
Thanks
The UISearchBar should be the UITableView's header view.
Had similar issue even when IB had the correct bouncing properties enabled.
In your viewDidLoad, set self.tableView.alwaysBounceVertical = YES;.