当前行为:用户必须向左滑动单元才能公开 *** 作按钮.
所需行为:用户在单元格上点击( *** 作按钮).单元格滑过以公开 *** 作按钮.
解决方法 那么我找不到一个方法来编程,但是我想出了这个解决方法.当用户点击单元格时,我将鼠标左键动画(平移),立即显示“滑动我”按钮.这很快就颠倒了,所以细胞恢复正常.这提供了一个视觉提示,让用户知道他们可以滑动单元格:- (voID)tableVIEw:(UItableVIEw *)tableVIEw dIDSelectRowAtIndexPath:(NSIndexPath *)indexPath{ UItableVIEwCell *cell = [tableVIEw cellForRowAtIndexPath:indexPath]; __block UILabel *swipeLabel = [[UILabel alloc]initWithFrame:CGRectMake(cell.bounds.size.wIDth,200,cell.bounds.size.height)]; swipeLabel.text = @" Swipe Me"; swipeLabel.backgroundcolor = [UIcolor greencolor]; swipeLabel.textcolor = [UIcolor whitecolor]; [cell addSubvIEw:swipeLabel]; [UIVIEw animateWithDuration:0.3 animations:^{ [cell setFrame:CGRectMake(cell.frame.origin.x - 100,cell.frame.origin.y,cell.bounds.size.wIDth,cell.bounds.size.height)]; } completion:^(BOol finished) { [UIVIEw animateWithDuration:0.3 animations:^{ [cell setFrame:CGRectMake(cell.frame.origin.x + 100,cell.bounds.size.height)]; } completion:^(BOol finished) { [swipeLabel removeFromSupervIEw]; swipeLabel = nil; }]; }];}
希望这有助于某人.
请注意,您需要将tableVIEwCell的选择类型设置为none.否则灰色的酒吧会掩盖它.
更新.我以为我会发布更多Swifty版本:
func prevIEwActions(forCellAt indexPath: IndexPath) { guard let cell = tableVIEw.cellForRow(at: indexPath) else { return } let label: UILabel = { let label = UILabel(frame: CGRect.zero) label.text = " Swipe Me " label.backgroundcolor = .blue label.textcolor = .white return label }() // figure out the best wIDth and update label.frame let bestSize = label.sizeThatFits(label.frame.size) label.frame = CGRect(x: cell.bounds.wIDth - bestSize.wIDth,y: 0,wIDth: bestSize.wIDth,height: cell.bounds.height) cell.insertSubvIEw(label,belowSubvIEw: cell.contentVIEw) UIVIEw.animate(withDuration: 0.3,animations: { cell.transform = CGAffinetransform.IDentity.translatedBy(x: -label.bounds.wIDth,y: 0) label.transform = CGAffinetransform.IDentity.translatedBy(x: label.bounds.wIDth,y: 0) }) { (finished) in UIVIEw.animateKeyframes(withDuration: 0.3,delay: 0.25,options: [],animations: { cell.transform = CGAffinetransform.IDentity label.transform = CGAffinetransform.IDentity },completion: { (finished) in label.removeFromSupervIEw() }) }}func tableVIEw(_ tableVIEw: UItableVIEw,dIDSelectRowAt indexPath: IndexPath) { prevIEwActions(forCellAt: indexPath) return}总结
以上是内存溢出为你收集整理的ios – UITableView以编程方式调用滑动 *** 作全部内容,希望文章能够帮你解决ios – UITableView以编程方式调用滑动 *** 作所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)