I would like to add a view to Scrollbar based on its frame as user scrolls down. This is already being done by below custom component (works fine till iOS 7)
https://github.com/honkmaster/TimeScroller
From iOS 8 there seems to be lot of changes in accessing the frame of Scrollbar from UitableView.
- (void)captureTableViewAndScrollBar
{
_tableView = [self.delegate tableViewForTimeScroller:self];
self.frame = CGRectMake(CGRectGetWidth(self.frame) - 10.0f, 0.0f, CGRectGetWidth(self.frame), CGRectGetHeight(self.frame));
for (UIView *subview in [_tableView subviews]){
if ([subview isKindOfClass:[UIImageView class]] && subview.tag == 0){
NSLog(@"check this SubViews %@ and its Tag %ld",subview , (long)subview.tag);
UIImageView *imageView = (UIImageView *)subview;
if (imageView.frame.size.width == 7.0f || imageView.frame.size.width == 5.0f || imageView.frame.size.width == 3.5f
|| imageView.frame.size.height == 2.5f){
imageView.clipsToBounds = NO;
[imageView addSubview:self];
_scrollBar = imageView;
_saved_tableview_size = _tableView.frame.size;
break;
}
}
}
}
Above is the code block to determine the ScrollBar Frame of Tableview
Based on the above rect we form the rect for view to be added and find the Corresponding TableviewCell by below code
CGRect selfFrame = self.frame;
CGRect scrollBarFrame = _scrollBar.frame;
NSLog(@"Check this %@",_scrollBar);
self.frame = CGRectMake(CGRectGetWidth(selfFrame) * -1.0f,
(CGRectGetHeight(scrollBarFrame) / 2.0f) - (CGRectGetHeight(selfFrame) / 2.0f),
CGRectGetWidth(selfFrame),
CGRectGetHeight(_backgroundView.frame));
CGPoint point = CGPointMake(CGRectGetMidX(self.frame), CGRectGetMidY(self.frame));
point = [_scrollBar convertPoint:point toView:_tableView];
UIView *view = [_tableView hitTest:point withEvent:nil];
Issue : ScrollBar frame Y didn't seems to be changing as user scrolls the tableView and hence hitTest fails to find the TableViewCell
Please find the sample ScrollBar frame of TableView > and its Tag 0
I need some help on How to accomplish the same on iOS 8.1 Version