gpt4 book ai didi

ios - UIGesture LongPress 复制单元格

转载 作者:行者123 更新时间:2023-11-30 13:57:17 25 4
gpt4 key购买 nike

我的表格 View 单元的 UI 遇到奇怪的交互缺陷。我实现了长按手势:

func handleLongPress(sender:UILongPressGestureRecognizer!) {

var myCharacters: SelectedCharacter?
let localLongPress = sender as UILongPressGestureRecognizer
let locationInView = localLongPress.locationInView(cardsListed)
let indexPath = charactersListed.indexPathForRowAtPoint(locationInView)
let listed = frc.objectAtIndexPath(indexPath!) as! Characters
let cell: firstCharacterDetails = charactersListed.dequeueReusableCellWithIdentifier("cell", forIndexPath: indexPath!) as! firstCharacterDetails

if listed == 0 {

} else {

if (sender.state == UIGestureRecognizerState.Ended) {
print("Long press Ended")
} else if (sender.state == UIGestureRecognizerState.Began) {
let bounds: CGRect = UIScreen.mainScreen().bounds
let screenHeight: NSNumber = bounds.size.height
if screenHeight == 480 {
let storyboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let characterDetailsController: CharacterDetailsViewController = storyboard.instantiateViewControllerWithIdentifier("characterDetails") as! CharacterDetailsViewController
characterDetailsController.modalPresentationStyle = UIModalPresentationStyle.Popover
let popoverplayersCharacterController = characterDetailsController.popoverPresentationController
popoverCharacterNoteController?.permittedArrowDirections = .Any
popoverCharacterNoteController?.delegate = self
popoverCharacterNoteController?.sourceView = cell.cardDescription
characterDetailsController.characterDetails = listed
self.presentViewController(characterDetailsController, animated: true, completion: nil)

}

这是一个示例,如果编码不完整,抱歉,因为我刚刚拿出了这部分代码以供引用。现在我的问题是一个非常独特的问题,并且仅可能在用户意外手势时发生,但为了用户的安全,我想消除此问题。

我面临的问题是,当用户长按手势选定的单元格时,如果他们在仍然按住该单元格的情况下意外地用手指拖动到另一个单元格,则实际上会复制自身或将自身拖动到用户长按手势拖动的单元格下方到。我不确定如何处理防止这种情况发生,但如果有人有任何见解,我们将不胜感激!

最佳答案

发现我做错了什么。第二次查看代码后,我意识到调用 dequeueResuableCell 是错误的函数。我用以下代码切换代码行:

let cell: firstCharacterDetails = charactersListed.cellForRowAtIndexPath(indexPath!) as! firstCharacterDetails

问题解决了。当我复制并粘贴在几个不同的 Controller 中重复使用的一些代码时,我并没有考虑太多。

关于ios - UIGesture LongPress 复制单元格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33456718/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com