sで使用UIPanGestureRecogniserしていUIButtonます。次の方法で2つが重なったことを検出したい:
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他のものにドラッグすることです。ユーザーがそれらのいずれかを離すと、プログラムはそれらのどれがオーバーラップしたか、およびからの相対を認識する必要があります。UIButtonUIButtondictionarykeydictionary
指定できるボタンは 1 つだけです。また、それがどのボタンであったかを理解し、からCGRectContainsPointを取得する方法もわかりません。 keydictionary