选择单元格后,用户应该可以选择其他几个选项.
我知道如何在选择单元格时推送另一个视图但我不喜欢这种方法.
例如,如果相同的单元格可以翻转并显示选项(然后翻转)可能会更轻松,这可能会更好.
或者整个单元格可以从屏幕滑出显示选项,或者另一个视图可以从单元格向下滑动然后向上滑动.
哪种解决方案最容易做到?
有人能指出我正确的方向吗?我当然不需要代码,我在这里学习,我只需要知道要看什么.
到目前为止,我已经阅读了关于UItableVIEwCell的子类化的内容,但老实说,我还没有得到它.
任何输入将不胜感激.
那说,你会在这里找到一个实现:https://github.com/spilliams/sparrowlike
重要的一点:
- (UItableVIEwCell *)tableVIEw:(UItableVIEw *)tableVIEw cellForRowAtIndexPath:(NSIndexPath *)indexPath{ static Nsstring *CellIDentifIEr = @"CustomCell"; UItableVIEwCell *cell = [tableVIEw dequeueReusableCellWithIDentifIEr:CellIDentifIEr]; if (cell == nil) { cell = [[UItableVIEwCell alloc] initWithStyle:UItableVIEwCellStyleDefault reuseIDentifIEr:CellIDentifIEr]; } // Configure the cell... UIPanGestureRecognizer *panGestureRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(handlePan:)]; [panGestureRecognizer setDelegate:self]; [cell addGestureRecognizer:panGestureRecognizer]; return cell;}#pragma mark - Gesture recognizer delegate- (BOol)gestureRecognizerShouldBegin:(UIPanGestureRecognizer *)panGestureRecognizer{ CustomCell *cell = (CustomCell *)[panGestureRecognizer vIEw]; CGPoint translation = [panGestureRecognizer translationInVIEw:[cell supervIEw] ]; return (fabs(translation.x) / fabs(translation.y) > 1) ? YES : NO;}#pragma mark - Gesture handlers-(voID)handlePan:(UIPanGestureRecognizer *)panGestureRecognizer{ float threshold = (PAN_OPEN_X+PAN_CLOSED_X)/2.0; float vX = 0.0; float compare; NSIndexPath *indexPath = [self.tableVIEw indexPathForCell:(CustomCell *)[panGestureRecognizer vIEw] ]; UIVIEw *vIEw = ((CustomCell *)panGestureRecognizer.vIEw).frontVIEw; switch ([panGestureRecognizer state]) { case UIGestureRecognizerStateBegan: if (self.openCellindexPath.section != indexPath.section || self.openCellindexPath.row != indexPath.row) { [self snapVIEw:((CustomCell *)[self.tableVIEw cellForRowAtIndexPath:self.openCellindexPath]).frontVIEw toX:PAN_CLOSED_X animated:YES]; [self setopenCellindexPath:nil]; [self setopenCellLastTX:0]; } break; case UIGestureRecognizerStateEnded: vX = (FAST_ANIMATION_DURATION/2.0)*[panGestureRecognizer veLocityInVIEw:self.vIEw].x; compare = vIEw.transform.tx + vX; if (compare > threshold) { [self snapVIEw:vIEw toX:PAN_CLOSED_X animated:YES]; [self setopenCellindexPath:nil]; [self setopenCellLastTX:0]; } else { [self snapVIEw:vIEw toX:PAN_OPEN_X animated:YES]; [self setopenCellindexPath:[self.tableVIEw indexPathForCell:(CustomCell *)panGestureRecognizer.vIEw] ]; [self setopenCellLastTX:vIEw.transform.tx]; } break; case UIGestureRecognizerStateChanged: compare = self.openCellLastTX+[panGestureRecognizer translationInVIEw:self.vIEw].x; if (compare > PAN_CLOSED_X) compare = PAN_CLOSED_X; else if (compare < PAN_OPEN_X) compare = PAN_OPEN_X; [vIEw settransform:CGAffinetransformMakeTranslation(compare,0)]; break; default: break; }}-(voID)snapVIEw:(UIVIEw *)vIEw toX:(float)x animated:(BOol)animated{ if (animated) { [UIVIEw beginAnimations:nil context:nil]; [UIVIEw setAnimationCurve:UIVIEwAnimationCurveEaSEOut]; [UIVIEw setAnimationDuration:FAST_ANIMATION_DURATION]; } [vIEw settransform:CGAffinetransformMakeTranslation(x,0)]; if (animated) { [UIVIEw commitAnimations]; }}总结
以上是内存溢出为你收集整理的ios – 选中时向表格单元格添加滑动视图全部内容,希望文章能够帮你解决ios – 选中时向表格单元格添加滑动视图所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)