如何获得放置在细胞和细胞indexpath中的tableview iOS中的滚动型编程方式创建视图位置

问题描述 投票:0回答:2

这是我的代码:

- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
{

 CGFloat pageWidth = scrollView.frame.size.width;

 int page = floor((scrollView.contentOffset.x - pageWidth / 2) / pageWidth) + 1;

 NSLog(@"Page No Scroll %i",page);

}
ios objective-c iphone ios7
2个回答
0
投票

您可以通过subview这样得到任何UIScrollView

for(UIView * subView in scrollView.subviews ) 
{ 
     // Here You can Get all subViews of your myScrollView.
}

0
投票
-(void)scrollViewDidScroll:(UIScrollView *)ScrollView
{
int scrollPositionX = callerScrollView.contentOffset.x;
if (callerScrollView == tbl_ProductView) return;
 for (UITableViewCell *cell in tbl_ProductView.visibleCells) {
UIScrollView cellScrollView = (UIScrollView )[cell viewWithTag:100];
if (callerScrollView == cellScrollView) continue;
NSInteger indexPath = callerScrollView.tag;
//NSLog(@"IndexPath Of Cell: %ld",(long)indexPath);
cellScrollView.contentOffset = CGPointMake(scrollPositionX, 0);
}
//ScollPage Position
static NSInteger previousPage = 0;
CGFloat pageWidth = callerScrollView.frame.size.width;
float fractionalPage = callerScrollView.contentOffset.x / pageWidth;
 NSInteger page = lround(fractionalPage);
  if (previousPage != page)
 {
   previousPage = page;
    NSLog(@"Scrolling Page: %li",(long)page);
 }
}
© www.soinside.com 2019 - 2024. All rights reserved.