我有UITableViewCell
一个UIScrollView
:
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];
使用UIButton
此代码可以解决此问题:
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
,但没有奏效。此外,我还尝试了一些其他的手势等等。但没有任何效果。
谁能帮我?
先感谢您。