Skip to content

Commit 176ab79

Browse files
committed
addReorderableView:gridPostition array index of range exception fixed
1 parent e79fbf5 commit 176ab79

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

ReorderableGridView-Swift/ReorderableGridView.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,13 @@ class ReorderableGridView: UIScrollView, Reorderable {
525525

526526
func addReorderableView (view: ReorderableView, gridPosition: GridPosition) {
527527
super.addSubview(view)
528-
reorderableViews.insert(view, atIndex: gridPosition.arrayIndex(colsInRow!))
528+
529+
var addingIndex = gridPosition.arrayIndex(colsInRow!)
530+
if addingIndex >= reorderableViews.count {
531+
addingIndex = reorderableViews.count
532+
}
533+
534+
reorderableViews.insert(view, atIndex: addingIndex)
529535
invalidateLayout()
530536
}
531537

0 commit comments

Comments
 (0)