How can i hide/show images while scrolling in UITableView? - ios

I'm new to iOS programming and i want to learn something about UITableView.
I have some images in UITableViewCell. I want to hide my images when scrolling start then i want to show them when scrolling stop.
How can i do that ?
Is there a method or something else about that ?

UITableView inherits from UIScrollView, thus you can in your tableView delegate receive
UIScrollViewDelegate callbacks.
Implement the delegate method
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView
which tells the delegate when the scroll view is about to start scrolling the content.
and
- (void)scrollViewWillEndDragging:(UIScrollView *)scrollView withVelocity:(CGPoint)velocity targetContentOffset:(inout CGPoint *)targetContentOffset
which tells the delegate when the user finishes scrolling the content.
Read the ScrollViewDelegate Reference.

It is not a big deal you simply need to implement scrollview delegated methodes to know when scrolling stops ,Then set a bool value and reload the table and on basis of bool value you can show and hide the images.When scrolling starts set bool to NO.

Related

When UITextView is scrolling ...?

I have a textView which is not editable so my textView is only readable. And there is a ImageView on the top of textView. I want that, when the textView is scrolling, ImageView (Y position) disappear slowly depends on How many the textView scrolled.. If I should give an example, it looks like Twitter "Me" page but non blurred. I hope I was clear.
First of call UIScrollViewDelegate, make your viewcontroller delegate to self.Because it's subclass of UIScrollview.
and implement scrollView function according to your need.Suppose you want to disappear image after scrolling finished. then implement this method.
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
{
NSLog(#"Finished scrolling");
}

Get the UIScrollView translation in view as the scroll happens?

I am trying to intercept the locationInView from the UIScrollView.panGestureRecognizer as the scroll is happening.
I was able to get the initial touch coordinates (when the scroll begins) implementing the following code inside the delegate method
#pragma mark UIScrollViewDelegate
- (void) scrollViewWillBeginDragging:(UIScrollView *)scrollView {
CGPoint point = [scrollView.panGestureRecognizer locationInView:scrollView];
NSLog(#"%#", NSStringFromCGPoint(point));}
Is there a way to get the coordinates continuously as the scroll is happening? I understand that the scrollView.panGestureRecognizer is a UIPanGestureRecognizer #property of the UIScrollView object, so there should be a panGestureDetected #selector somewhere.
Thx in advance.... e
Add the UIScrollViewDelegate method:
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
And in there you can access the scrollView while it is scrolling. If you are not using a view that subclasses UIScrollView, be sure to explicitly implement the UIScrollViewDelegate. I assume that you should not have to since the delegate method in your question is being called but I just thought I would point that out.
Be sure you really want to use the locationInView: method because it will return the point of the gesture and not the contentOffset of the UIScrollView. In other words, the gesture point may be outside of the desired range, where the contentOffset is in direct relation to the UIScrollView object.
EDIT:
Just as an FYI, the method will be called a lot, so make sure you are not doing any heavy processing every time the method is called.

Make UIView under a UITableView visible when you scroll

I have a UITableView that's placed on top of a UIView.
So basically, it looks like this:
I have a tableviewHolder which has two subviews
1.) UIView with other subviews
2.) UITableView
Whenever the user scrolls the UITableView, i want the UIView beneath it to be visible.
I tried setting the UITableView's background to clear and it works. However, if the tableview's background is clear, then other portion of the UIView beneath it would be visible when the rows of the cell are not enough to cover the whole table.
How can I change the background color of the table view and still make the UIView beneath it visible whenever the user scrolls?
Use
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView
(ref https://developer.apple.com/library/ios/documentation/uikit/reference/UIScrollViewDelegate_Protocol/Reference/UIScrollViewDelegate.html#//apple_ref/occ/intfm/UIScrollViewDelegate/scrollViewWillBeginDragging: )
This method will be called when the UITableView begins scrolling. So, in this method, set the UIView to visible
view.setAlpha=1.0;
and in
- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate
set the uIView to invisible again by using
view.setAlpha=0.0;
Am asking you to use UIScrollViewDelegate methods in a UITableViewDelegate class. This will work because UITableViewDelegate inherits from UIScrollViewDelegate. So all methods in UIScrollViewDelegate will also work for UITableViewDelegate.

Make Keyboard Disappear when UITableView Scrolls

I have a UITextField at the top of my Table View, after the text field is selected I want the keyboard to disappear. I know to call [[self view] endEditing:YES]; but I don't know how to check for the scroll. A good example of this is IMessage, when the keyboard is in view you can scroll up to collapse it, I want my table view to work inversely.
UITableView is a subclass of UIScrollView. By being the table delegate (implementing <UITableViewDelegate>) you are also the scroll view delegate (<UIScrollViewDelegate>) and as such you can implement:
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
Then you will receive a notification whenever the table view is scrolled. You can then also use scrollView.contentOffset to check where the table has scrolled to (which direction it's scrolling in).
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
[textField resignFirstResponder];
}
Try other method in UIScrollViewDelegate if you need other behaviour.
Call resignFirstResponder where appropriate.
It seems you use UITextField in your cells. Use UITextFieldDelegate protocol to know when UITextField ends being edited:
-(void)textFieldDidEndEditing:(UITextField*)textField
{
[textField resignFirstResponder];
}

Table view scrolling event

Is there any event in table view which will get triggered when i try to scroll the table view.
I want to create a down arrow image to the bottom of the table view ,when the user tries to scroll through the table view.Any help will be appreciated.
Thanks,
Christy
As far as i recall, since UITableView Inherits from UIScroll view you can listen to the UIScrollViewDelegate methods:
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
}
- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView
willDecelerate:(BOOL)decelerate
{
}
Any way. make sure that
tableView.delegate=self;

Resources