Objective c 如何获取UIScrollView的索引?

Objective c 如何获取UIScrollView的索引?,objective-c,uitableview,uiscrollview,nsindexpath,Objective C,Uitableview,Uiscrollview,Nsindexpath,我有一个带有UIScrollView的UITableViewCell: cellScroll = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 320, 43)]; cellScroll.contentSize = CGSizeMake(960, 43); cellScroll.contentOffset = CGPointMake(320, 0); cellScroll.decelerationRate = UIScrollViewD

我有一个带有
UIScrollView
UITableViewCell

cellScroll = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 320, 43)];
cellScroll.contentSize = CGSizeMake(960, 43);
cellScroll.contentOffset = CGPointMake(320, 0);
cellScroll.decelerationRate = UIScrollViewDecelerationRateFast;
[cell addSubview:cellScroll];
使用
ui按钮
可通过以下代码解决此问题:

UIView *animationView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 960, 43)];
[cellScroll addSubview:animationView];

cellButton = [UIButton buttonWithType:UIButtonTypeCustom];
cellButton.frame = CGRectMake(320, 0, 320, 43);
[cellButton addTarget:self action:@selector(didPushCellButton:event:) forControlEvents:UIControlEventTouchUpInside];

[animationView addSubview:cellButton];

- (void)didPushCellButton:(id)sender event:(id)event {        
NSSet *touches = [event allTouches];
UITouch *touch = [touches anyObject];
CGPoint currentTouchPosition = [touch locationInView:theTable];
NSIndexPath *indexPath = [theTable indexPathForRowAtPoint:currentTouchPosition];
}
我也用
UIScrollView
尝试了这一点,但没有成功。 此外,我还尝试了一些其他的动作和更多的东西。 但什么都不管用

有人能帮我吗


提前谢谢。

您能解释一下什么时候以及为什么需要
indepath
,因为您的按钮代码似乎已经在工作了?这可能有助于某人理解上下文并帮助您解决问题。对于
ui按钮
来说,它是有效的,但对于
UIScrollView
来说则不然,这就是问题所在。我说:“有了UIButton,这个问题就用这个代码解决了:”