I have a top view and a tableview below it. My requirement is while table view is scrolling up, the top view should also scroll up along with the first row. When the table view scrolls down the top view should also scroll along with the current row (not after all rows scrolls down).
Hope I'm clear on above. If anyone has some working code, will appreciate your help.
Thank You.
You can use this delegate for this
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
CGPoint point =quotesTableView.contentOffset;
//Do your coading in this
}
Related
I am writing a simple iphone app. I have:
- A search bar at the top
- A table view below that
I've got another table view which gets displayed under the search bar once the user starts typing, showing suggestions for what they might mean. When shown this table view overlaps with the main table view mentioned above.
The problem I have is that I cant scroll the table view showing suggestions. When I try to it scrolls the table view it's overlapping instead.
Any thoughts on how to make the suggestions table view scroll? I could be doing something silly - I'm very new to iphone programming.
Thanks!
The problem seems to be that I was adding the table view holding the suggestions to the search bar, adding it to the search bar's parent seems to have fixed it. I.e:
[[searchBar superview] addSubview:tableView];
I assume the logic is that I can only receive touch events that overlap with my views parent area.
I have a mockup that looks like this:
This is all one big Table Controller that you can scroll.
When the section header hits the top of the page it freezes along the top, like so:
Which is working fine. However, when you go back to the top and do a pull to refresh, I want it to do this:
So the pull to refresh dialog appears between the top table header cell and the section header (that is no longer frozen).
Is this possible? I haven't found an implementation like this in my searches.
You can do the following to achieve this,
Add a UIScrollView as the subview of UIViewController's view.
Add a UIView and UITableView as the subview of this scroll view
UIView inside scroll view represents table header cell.
Section header can be the header of UITableview and table contents represents the UITableView's cells.
Add UIRefreshControl as subview of UITableView and set its target method.
Implement the scrollview delegate - (void)scrollViewDidScroll:(UIScrollView *)scrollView for both UITableview and UIScrollview.
When you are scrolling the tableview, move the parent scrollview whenever the table view header moves in the upward direction till the header reaches the top. Add an if condition in scrollview delegate to check for this.
When the table view is moved the downward direction, move the parent scrollview until the UIView table cell header is visible after this stop scrolling of UIScrollview and allow table view to scroll. This will enable the UIRefreshControl.
Here the key thing is the - (void)scrollViewDidScroll:(UIScrollView *)scrollView method and how you implement the scrolling. You can add a check for contentOffset to determine how much tableview and scrollview has been scrolled. In order to restrict the scrolling you can manually set this value in this delegate method to a particular value and it wont scroll after that.
I use UITableViewController, and I implement
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView
{
//my code
}
inside "//my code", how can I know that the scroll event was fired from tableheaderview area, not anywhere else in my table, in other words, how to know that the start of scrolling event was in table header view or not.
Thanks in advance.
NSLog(#"scrollView.contentOffset.y= %f",scrollView.contentOffset.y); and
NSLog(#"scrollView.contentOffset.x= %f",scrollView.contentOffset.x);
using these you can get the position of the scrolling tableview.may be it will help you.
I have a custom view covering entire screen in iPod touch. I need to put add another view in this which will initially be hidden but will come on screen when view is scrolled down. I hav achieved this but not I can scroll my view to upside also. I so not want user to pull up the custom view. I just want a pull down feature and no pull up.
When someone pull down I am bringing the view to original position programatically. So, when user pull down they can see some information for 5 secs and then view is back to original position.
Hoe can I restrict my UIScrollView from being scrolled towards up on manual interaction?
I did this by following code. Its working now.
(void)scrollViewDidScroll:(UIScrollView *)iScrollView {
// Refrain the view from scrolling up
if (iScrollView.contentOffset.y > 0.0) {
iScrollView.contentOffset = CGPointZero;
}
}
I have 2 table view, with the same number of cells.
Could you please point me the correct way, that I could implement simultaneous scrolling. I mean, when I scroll through one table, the other one is scrolling the same time. Thanks.
As uitable view is derived from uiscrollview you can get the scroll amounts in the delegate method
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
You can get content offset of the scrollview which is being scrolled and assign that to the other tableview.
In this method you should be able to access both tableviews.
The property you need to check is contentOffset.
firsttableview.contentOffset = scrollview.contentOffset