Я использую UIPanGestureRecogniser
по адресу UIButton
s. Я хочу, чтобы обнаружить, когда два из них пересекаются следующим образом:Обнаружение перекрытия с UIPanGestureRecognizer
if([(UIPanGestureRecognizer*)sender state] == UIGestureRecognizerStateEnded ||
[(UIPanGestureRecognizer*)sender state] == UIGestureRecognizerStateCancelled ||
[(UIPanGestureRecognizer*)sender state] == UIGestureRecognizerStateFailed) {
CGPoint fingerPoint;
for(id key in BluetoothDeviceDictionary) {
UIButton* btn = [BluetoothDeviceDictionary objectForKey:key];
fingerPoint = [(UIPanGestureRecognizer*)sender locationInView:btn.superview];
}
//BLUETOOTH SHARING
if (CGRectContainsPoint(All buttons from dictionary.frame, fingerPoint)) {
for the UIButton that has been overlapped do...
Что в основном происходит, что пользователь перетаскивает UIButton
на любой другой UIButton
в серии UIButton
с на экране, которые являются частью dictionary
, Когда пользователь выпускает какой-либо из них, программа должна распознавать, какая из них перекрывается, и относительная key
от dictionary
.
Я могу указать только одну кнопку для CGRectContainsPoint
, и я также не знаю, как понять, какая из кнопок была, и получить key
от dictionary
.