Permalink
Browse files

Always add the modal view to the root view, not the current one - thi…

…s mimics standard modal view behaviour better
  • Loading branch information...
1 parent 286dd39 commit 2e3dbd72f8a3582e08685ba8e104d08c373a6a54 @reednj committed Oct 18, 2012
Showing with 7 additions and 6 deletions.
  1. +7 −6 Source/UIViewController+TDSemiModalExtension.m
@@ -14,22 +14,23 @@ @implementation UIViewController (TDSemiModalExtension)
- (void) presentSemiModalViewController:(TDSemiModalViewController*)vc {
UIView* modalView = vc.view;
UIView* coverView = vc.coverView;
-
- coverView.frame = self.view.bounds;
+ UIView *rootView = UIApplication.sharedApplication.delegate.window.rootViewController.view;
laszlotuss
laszlotuss Dec 15, 2012

This line supposed to be:
UIView *rootView = UIApplication.sharedApplication.delegate.window.rootViewController.presentedViewController.view

reednj
reednj Dec 17, 2012 Owner

Can you explain what the advantage is with that? It works better when showing the modal view inside another modal view or something?

lironsher
lironsher Feb 13, 2013

Hi
i think the line should be:
UIView *rootView = self.view;

There is a bug in IOS, where the the view pointer you get is not always the one that is the top.

thanks

+
+ coverView.frame = rootView.bounds;
coverView.alpha = 0.0f;
- modalView.frame = self.view.bounds;
+ modalView.frame = rootView.bounds;
modalView.center = self.offscreenCenter;
- [self.view addSubview:coverView];
- [self.view addSubview:modalView];
+ [rootView addSubview:coverView];
+ [rootView addSubview:modalView];
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.6];
modalView.frame = CGRectMake(0, 0, modalView.frame.size.width, modalView.frame.size.height);
coverView.alpha = 0.5;
-
+
[UIView commitAnimations];
}

0 comments on commit 2e3dbd7

Please sign in to comment.