Skip to content

Commit

Permalink
For iOS versions under 5.0, force/simulate calls to viewDidAppear & v…
Browse files Browse the repository at this point in the history
…iewDidDisappear.

Please note that the timing is different than for the calls made by the system and you may need to take that into account.
  • Loading branch information
gumbright committed Nov 28, 2011
1 parent de2e97e commit bd8d7d9
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 3 deletions.
17 changes: 17 additions & 0 deletions UIXOverlayController files/UIXOverlayController.m
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -150,6 +150,10 @@ - (void)maskFadeInComplete:(NSString *)animationID finished:(NSNumber *)finished
{ {
[overlayDelegate overlayContentDisplayed:self]; [overlayDelegate overlayContentDisplayed:self];
} }
if ([[UIDevice currentDevice].systemVersion floatValue] < 5.0)
{
[_contentController viewDidAppear:YES];
}
}]; }];


} }
Expand All @@ -176,6 +180,10 @@ - (void) detachOverlay
/////////////////////////////////////////////// ///////////////////////////////////////////////
- (void)maskFadeOutComplete:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context - (void)maskFadeOutComplete:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context
{ {
if ([[UIDevice currentDevice].systemVersion floatValue] < 5.0)
{
[_contentController viewDidDisappear:YES];
}
[self detachOverlay]; [self detachOverlay];
} }


Expand Down Expand Up @@ -223,6 +231,11 @@ - (void) presentOverlayOnView:(UIView*) parentView withContent:(UIXOverlayConten
_contentController.view.frame = placement; _contentController.view.frame = placement;


[maskView addSubview:_contentController.view]; [maskView addSubview:_contentController.view];

if ([[UIDevice currentDevice].systemVersion floatValue] < 5.0)
{
[contentController viewDidAppear:NO];
}
} }
} }


Expand Down Expand Up @@ -260,6 +273,10 @@ - (void) dismissOverlay:(BOOL) animated;
} }
else else
{ {
if ([[UIDevice currentDevice].systemVersion floatValue] < 5.0)
{
[_contentController viewDidDisappear:NO];
}
[self detachOverlay]; [self detachOverlay];
} }
} }
Expand Down
14 changes: 12 additions & 2 deletions UIXOverlayController/DialogContentViewController.m
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -57,6 +57,16 @@ - (void)viewDidUnload
// e.g. self.myOutlet = nil; // e.g. self.myOutlet = nil;
} }


- (void) viewDidAppear:(BOOL)animated
{
NSLog(@"appear");
}

- (void) viewDidDisappear:(BOOL)animated
{
NSLog(@"disappear");
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{ {
// Return YES for supported orientations // Return YES for supported orientations
Expand All @@ -66,12 +76,12 @@ - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interface


- (IBAction) yesPressed:(id) sender - (IBAction) yesPressed:(id) sender
{ {
[self.overlayController dismissOverlay:YES]; [self.overlayController dismissOverlay:DIALOG_ANIMATED];
} }


- (IBAction) noPressed:(id) sender - (IBAction) noPressed:(id) sender
{ {
[self.overlayController dismissOverlay:YES]; [self.overlayController dismissOverlay:DIALOG_ANIMATED];
} }


@end @end
3 changes: 3 additions & 0 deletions UIXOverlayController/UIXOverlayController-Prefix.pch
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -11,4 +11,7 @@
#ifdef __OBJC__ #ifdef __OBJC__
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>

#define DIALOG_ANIMATED NO

#endif #endif
2 changes: 1 addition & 1 deletion UIXOverlayController/UIXOverlayControllerViewController.m
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ - (IBAction) showDialog:(id) sender


DialogContentViewController* vc = [[DialogContentViewController alloc] init]; DialogContentViewController* vc = [[DialogContentViewController alloc] init];


[overlay presentOverlayOnView:self.view withContent:vc animated:YES]; [overlay presentOverlayOnView:self.view withContent:vc animated:DIALOG_ANIMATED];
} }


- (void) overlayRemoved:(UIXOverlayController*) overlayController - (void) overlayRemoved:(UIXOverlayController*) overlayController
Expand Down

0 comments on commit bd8d7d9

Please sign in to comment.