File tree Expand file tree Collapse file tree
Examples/SpringBoard/Classes Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -199,6 +199,11 @@ - (void) moveActionGestureRecognizerStateChanged: (UIGestureRecognizer *) recogn
199199 {
200200 CGPoint p = [recognizer locationInView: _gridView];
201201 NSUInteger index = [_gridView indexForItemAtPoint: p];
202+ if ( index == NSNotFound )
203+ {
204+ // index is the last available location
205+ index = [_icons count ] - 1 ;
206+ }
202207
203208 // update the data store
204209 id obj = [[_icons objectAtIndex: _dragOriginIndex] retain ];
@@ -282,6 +287,14 @@ - (void) moveActionGestureRecognizerStateChanged: (UIGestureRecognizer *) recogn
282287
283288 // update empty cell to follow, if necessary
284289 NSUInteger index = [_gridView indexForItemAtPoint: [recognizer locationInView: _gridView]];
290+
291+ // don't do anything if it's over an unused grid cell
292+ if ( index == NSNotFound )
293+ {
294+ // snap back to the last possible index
295+ index = [_icons count ] - 1 ;
296+ }
297+
285298 if ( index != _emptyCellIndex )
286299 {
287300 NSLog ( @" Moving empty cell from %u to %u " , _emptyCellIndex, index );
You can’t perform that action at this time.
0 commit comments