Skip to content

Commit

Permalink
fixed view hierarchy index when leaving fullscreen
Browse files Browse the repository at this point in the history
  • Loading branch information
Arnaud Coomans committed Mar 2, 2012
1 parent 42bded0 commit 87b6c2d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions PSPushPopPressView.h
Expand Up @@ -45,6 +45,7 @@
CGAffineTransform rotateTransform_;
CGAffineTransform panTransform_;
CGRect initialFrame_;
NSInteger initialIndex_;
BOOL allowSingleTapSwitch_;
BOOL fullscreen_;
BOOL ignoreStatusBar_;
Expand Down
4 changes: 3 additions & 1 deletion PSPushPopPressView.m
Expand Up @@ -51,6 +51,7 @@ - (id)initWithFrame:(CGRect)frame_ {
rotateTransform_ = CGAffineTransformIdentity;
panTransform_ = CGAffineTransformIdentity;
initialFrame_ = frame_;
initialIndex_ = 0;
allowSingleTapSwitch_ = YES;

UIPinchGestureRecognizer* pinchRecognizer = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(pinchPanRotate:)];
Expand Down Expand Up @@ -152,14 +153,15 @@ - (BOOL)detachViewToWindow:(BOOL)enable {
UIView *rootView = [self rootView];

if (enable && !initialSuperview_) {
initialIndex_ = [self.superview.subviews indexOfObject:self];
initialSuperview_ = self.superview;
CGRect newFrame = [self.superview convertRect:initialFrame_ toView:rootView];
[rootView addSubview:self];
[self setFrame:newFrame];
viewChanged = YES;
}else if(!enable) {
if (initialSuperview_) {
[initialSuperview_ addSubview:self];
[initialSuperview_ insertSubview:self atIndex:initialIndex_];
viewChanged = YES;
}
[self setFrame:initialFrame_];
Expand Down

0 comments on commit 87b6c2d

Please sign in to comment.