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.
Related
My self.view has a UIScrollView as a subview. This UIScrollView has a container UIView, which holds many UITableView's as subviews. These subviews are all configured using autolayout constraints.
So basically my scrollview is horizontally scrollable. I also have UILongPressGesture inside my UIScrollView.
My problem is didSelectItemAtIndexPath is not called while tapping over the cells inside UITableView. I have set cancelTouchesInView to NO for my UILongPressGesture but still didSelectItemAtIndexPath doesn't get called.
I don't want to add UITapGestureRecognizer to my UIScollView and manually trigger didSelectItemAtIndexPath , since I'm doing some operations in UITableView delegate methods.
How can I make my UITableView to responds to all of its delegate methods ?
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");
}
I have a UITableViewController. In one of my prototype cells there is a UIScrollView with horizontal paging and a page control. I have set this up in storyboard, laying out all the elements that will display on each page of the UIScrollView, exactly how I have set a scroll view up in the past in a UIViewController. Since this UIScrollView is inside a UITableViewCell, I am confused about how to connect the page control.
1) Should the code to change the page control be in the cell class file? And if so what would that look like?
2) Also do I implement the UIScrollViewDelegate inside the UITableViewController or inside the UITableViewCell class file?
(this is in objective-c)
Having the UIPageControl code inside of the cell class seems to be the most appropriate choice. The view controller which is displaying the table/cells shouldn't be delegating this type of internal behaviour.
If you're implementing the code in the cell class then the cell class would need to conform to the UIScrollViewDelegate protocol in order to receive the scrollViewDidScroll: message. The table view controller wouldn't be involved.
This is what it the method would look like:
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
CGFloat pageIndex = self.scrollView.contentOffset.x / CGRectGetWidth(self.scrollView.frame);
self.pageControl.currentPage = lround(pageIndex);
}
Also make sure to set the pagingEnabled property on the scrollview to YES.
i am new in Google admob development. In this case i need to add an admob inside my uitableview, I make an implementation like this on :
the problem is, the cell that contain the ads (I Use DFPBannerView) is scrollable, i want to make it unscrollable. I just want to make the uitableview scrollable but the banner view is not. I already implement some suggestion from UIScrollView doesn't scroll when touching GADBannerView subview
but it still can not make the ads unscrollable. is there anyone can help me?
There are basic 2 solutions to this:
Add the view to the superview of your table view instead of to the table view itself. Then you just set the frame of the tableview to be shorter so that it is not cut off by the banner. This is provided you are not using a UITableViewController because if you're using one of those, the table view is the root view.
Add the subview to your tableview directly, and implement scrollViewDidScroll: and change its frame based on that. The implementation would look something like this:
- (void) scrollViewDidScroll:(UIScrollView *)scrollView
{
CGRect bannerFrame = myBanner.frame;
bannerFrame.origin.y = CGRectGetMaxY(scrollView.bounds) - bannerFrame.size.height;
myBanner.frame = bannerFrame;
}
I have a UITableView inside a UIView inside a UIScrollView.
Problem: when i scroll/drag the tableview, the scrollview scrolls too.
What i need is for the tableview not to pass the scroll to the scrollview. Also i need to be able to use the scrollview when i scroll it directly.
How can i do this?
Cheers
I fixed it using "hitTest" on the tableview.
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event
If the event originated within the tableview, i disable the parent's scrollview scroll.
And, when the tableview's scroll has ended (scrollViewDidEndDragging) i re-enable the parent's scrollview scroll.
This seams to work fine.
Set a delegate to your tableview's scrollview (i.e your view controller)
tableView.scrollView.delegate = self;
then use those two calls
– scrollViewDidScroll:
– scrollViewDidEndDragging:willDecelerate:
to disable and re-enable your outside scrollview's scrollEnabled property