Skip to content

Commit

Permalink
BUG修复
Browse files Browse the repository at this point in the history
  • Loading branch information
@欧柏泉 committed May 2, 2016
1 parent 004aa96 commit c8d425c
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions MyLayout/FLLTest3ViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
@interface FLLTest3ViewController ()

@property(nonatomic, strong) MyFlowLayout *flowLayout;
@property(nonatomic, assign) BOOL oldIndex;
@property(nonatomic, assign) BOOL currentIndex;
@property(nonatomic, assign) NSInteger oldIndex;
@property(nonatomic, assign) NSInteger currentIndex;

@end

Expand Down Expand Up @@ -109,7 +109,6 @@ - (IBAction)handleTouchDrag:(UIButton*)sender withEvent:(UIEvent*)event {
CGPoint pt = [[event touchesForView:sender].anyObject locationInView:self.flowLayout];

UIView *sbv2 = nil;

//判断当前手指在具体视图的位置。
for (UIView *sbv in self.flowLayout.subviews)
{
Expand All @@ -126,6 +125,7 @@ - (IBAction)handleTouchDrag:(UIButton*)sender withEvent:(UIEvent*)event {

if (sbv2 != nil)
{

//把所有子视图
self.flowLayout.beginLayoutBlock = ^{

Expand All @@ -140,7 +140,7 @@ - (IBAction)handleTouchDrag:(UIButton*)sender withEvent:(UIEvent*)event {
};

//得到要移动的视图的位置索引。
self.currentIndex = [self.flowLayout.subviews indexOfObject:sbv2];
self.currentIndex = [self.flowLayout.subviews indexOfObjectIdenticalTo:sbv2];

if (self.oldIndex != self.currentIndex)
{
Expand All @@ -151,6 +151,8 @@ - (IBAction)handleTouchDrag:(UIButton*)sender withEvent:(UIEvent*)event {
self.currentIndex = self.oldIndex + 1;
}



//因为sender在bringSubviewToFront后变为了最后一个子视图,因此要调整正确的位置。
for (NSInteger i = self.flowLayout.subviews.count - 1; i > self.currentIndex; i--)
{
Expand Down

0 comments on commit c8d425c

Please sign in to comment.