gpt4 book ai didi

ios - 点击并从一个 UITable 拖动到其下方的另一个 UITable

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

我有两个 UITable,一个在另一个之上。用户可以点击并将元素从顶部表格拖动到底部。当元素被拖动到底部表格上时,它就会消失。

当表格并排时,不会出现此问题。

线索/症状可能是;当您滚动顶部表格时,如果您继续将手指向下移动经过顶部表格并越过底部表格,则顶部表格将继续滚动。就好像表格一直延伸到屏幕底部一样,尽管事实并非如此。

这个问题似乎也只发生在 4 英寸屏幕上。

这是拖放功能:

    func dragAndDrop( pangesture : UIPanGestureRecognizer)
{
print("dragAndDrop \(pangesture.state.rawValue) section=\(section) row=\(row)")
if(pangesture.state == UIGestureRecognizerState.Ended)
{
if(section == nil)
{
return
}

let locationInView : CGPoint! = pangesture.locationInView(self.tbldrag)
if (CGRectContainsPoint(self.tbldrag.bounds, locationInView))
{
var moods : [Mood] = getMoodsWithRO(mClient.getRooms()[self.section].getRoomID())

//dropped to To table
self.arrDroproom.append(mClient.getRooms()[self.section].getName())

var temp:Mood = moods[self.row]

if(moods[self.row].getMoodName() == "Space Off")
{
self.arrDropdata.append(mClient.getRooms()[self.section].getRoomID())
}
else
{
self.arrDropdata.append(moods[self.row].getMoodID())
}

self.arrDropmood.append(moods[self.row].getMoodName())
self.cellDrag.removeFromSuperview()
self.tblMoods.reloadData()
self.tbldrag.reloadData()

addDelayButton.enabled = true

return
}
self.section = nil
self.row = nil
if((self.cellDrag) != nil)
{
self.cellDrag.removeFromSuperview()
}
self.tblMoods.reloadData()
self.tbldrag.reloadData()
self.isHorizontalGeasture = false
}
else if(pangesture.state == UIGestureRecognizerState.Began)
{
let vel : CGPoint = pangesture.velocityInView(self.tblMoods)
//println(vel)

let isVerticalGesture : Bool = fabs(vel.y) > fabs(vel.x)

var a = "horiz"
if(isVerticalGesture)
{
a="vert"
}
print("began: gesture is \(a)")


if((UIDevice.currentDevice().userInterfaceIdiom != .Phone && isVerticalGesture==false) || (UIDevice.currentDevice().userInterfaceIdiom == .Phone))
{
self.isHorizontalGeasture = !isVerticalGesture
if (vel.x > 0)
{
//NSLog("towards the right")
}
else
{
//NSLog("towards the left")
}
let touchLocation1 : CGPoint! = pangesture.locationInView(self.tblMoods)

let indexPath : NSIndexPath? = self.tblMoods.indexPathForRowAtPoint(touchLocation1)

if(indexPath != nil)
{
self.section = indexPath!.section
self.row = indexPath!.row
self.cellDrag = self.tblMoods.cellForRowAtIndexPath(indexPath!)!

self.view.addSubview(self.cellDrag)
}
}
}
else
{
if((UIDevice.currentDevice().userInterfaceIdiom != .Phone && self.isHorizontalGeasture) || (UIDevice.currentDevice().userInterfaceIdiom == .Phone))
{
let touchLocation : CGPoint! = pangesture.locationInView(self.view)

self.cellDrag.center = touchLocation
}
else
{
pangesture.delegate = nil
}

}
}

最佳答案

我找到了答案:当问题发生时,它会发送一个 Canceled 事件。

“您几乎应该始终使用 UIGestureRecognizerState.Ended || UIGestureRecognizerState.Cancelled,因为在手势结束时肯定会调用两者之一。这样您还可以处理用户拖动过屏幕的情况。”

关于ios - 点击并从一个 UITable 拖动到其下方的另一个 UITable,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34272435/

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