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.
Related
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
}
I want to hide the keyboard when I scroll on TableView. That means, I search for an item and I see the results, when I scroll on the TableView the keyboard will hide or dismiss. Look at this image.
You need to track the action that runs when the tableView is being scrolled. UITableView is the subclass of UIScrollView. So, you can use all the methods from UIScrollViewDelegate for your table.
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
[textfield resignFirstResponder];
}
This will work.
Set up the scrollview delegate in your header then make it so when
- (void)scrollViewWillBeginDragging:(UIScrollView*)scrollview{
[self.textfield resignFirstResponder];}
and when he stops scrolling
- (void)scrollViewDidEndDragging:(UIScrollView*)scrollview willDecelerate:YES{
//open keyboard back up}
edit:
my bad, i confused scrollview and tableview. disregard anything up there, i cant find anything for your problem
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
initially i crate 2 textfields in main view.
And i write IBAction to them and give touch down in interface builder.
But unfortunately i need to place scroll view in view and place these two text fields on scrollview.
in the IBAction i am calling action sheet. before adding scroll view it works fine but after adding scroll view need to long press other wise keypad will raise instead of Action sheet
what the wrong can any one pls help me.
Thank u in advance.
Is it possible to forward the touch the the scroll view? Not sure if it is but just an idea?
Hey try this UITextFieldDelegate method
This will not raise the keypad
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField
{
return NO;
}
Do let me know if ths works
I think have decent experience working with iPhone development.
as much I know.. I did set up the delegate..
I have from top to botton
UIView --> UIScrollView--> UITextView
I tried everything... to get the event scrollView to fire the scrollViewDidScroll event.
is anything wrong with the structure..
there not much of the code to post here.
what I am trying to do is.. do something when UITextView is scrolled.
Sorry did not respond... Just wanted to share in case anyone need this...
I used delegate methods of parent i.e. UIView for UIScrollView i.e. Child it worked..
It's hard to say without some code or a screenshot. Is the scroll view actually scrolling? If you set it up in Interface Builder, did you change the size of the scroll view's contentSize in code so that it can actually scroll? Maybe the text view is eating the scroll events; did you try setting the text view's delegate to see if it's firing a scrollViewDidScroll event?