Skip to content
This repository has been archived by the owner on Feb 27, 2023. It is now read-only.

Commit

Permalink
Now added as a subview of the window (fix #1).
Browse files Browse the repository at this point in the history
  • Loading branch information
radutzan committed Feb 11, 2013
1 parent 76f35c4 commit 0aa66de
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 17 deletions.
15 changes: 4 additions & 11 deletions OLGhostAlertView.m
Original file line number Diff line number Diff line change
Expand Up @@ -195,22 +195,15 @@ - (id)initWithTitle:(NSString *)title
- (void)show
{
UIWindow *window = [[[UIApplication sharedApplication] delegate] window];
UIView *parentView;

if (window.rootViewController.presentedViewController) {
parentView = window.rootViewController.presentedViewController.view;
} else {
parentView = window.rootViewController.view;
}

for (UIView *subView in [parentView subviews]) {
for (UIView *subView in [window subviews]) {
if ([subView isKindOfClass:[OLGhostAlertView class]]) {
OLGhostAlertView *otherOLGAV = (OLGhostAlertView *)subView;
[otherOLGAV hide];
}
}

[parentView addSubview:self];
[window addSubview:self];

[UIView animateWithDuration:0.5 animations:^{
self.alpha = 1;
Expand Down Expand Up @@ -320,11 +313,11 @@ - (void)setPosition:(OLGhostAlertViewPosition)position
break;

case OLGhostAlertViewPositionCenter:
yPosition = ceilf((screenRect.size.height / 2) - (self.frame.size.height / 2));
yPosition = ceilf((screenRect.size.height / 2) - (self.frame.size.height / 2)) + 10;
break;

case OLGhostAlertViewPositionTop:
yPosition = self.bottomMargin;
yPosition = self.bottomMargin + 20;
break;
}

Expand Down
4 changes: 2 additions & 2 deletions OLGhostAlertView.podspec
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
Pod::Spec.new do |s|
s.name = 'OLGhostAlertView'
s.version = '1.2'
s.version = '1.2.1'
s.license = 'Public Domain'
s.platform = :ios
s.summary = 'Temporary and unobtrusive translucent alert view for iPhone and iPad.'
s.homepage = 'https://github.com/ondalabs/OLGhostAlertView'
s.authors = { 'Radu Dutzan' => '[email protected]'}
s.source = { :git => 'https://github.com/ondalabs/OLGhostAlertView.git', :tag => '1.2' }
s.source = { :git => 'https://github.com/ondalabs/OLGhostAlertView.git', :tag => '1.2.1' }
s.source_files = 'OLGhostAlertView.{h,m}'
s.requires_arc = true

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,7 @@
7CAA785B16C1CF4C0088E893 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
Expand Down
4 changes: 1 addition & 3 deletions OLGhostAlertViewDemo/OLGhostAlertViewDemo/OLViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,8 @@ - (void)loadView
self.view.backgroundColor = [UIColor lightGrayColor];
}

- (void)viewDidLoad
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidLoad];

OLGhostAlertView *demo = [[OLGhostAlertView alloc] initWithTitle:@"Hi there." message:nil timeout:5.0 dismissible:NO];
demo.position = OLGhostAlertViewPositionTop;
demo.completionBlock = ^(void) {
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ After that, here's how you present an OLGhostAlertView:

Just like with UIAlertView, the dismissal of the view is handled by the view itself, so there's no need to call anything else. If you do want to dismiss it manually, just call `hide` on the instance.

OLGhostAlertView has to be `show`n in or after `viewDidAppear:` is invoked on the Root View Controller. If you attempt to call `show` before that, the instance may not be visible on the screen.

### Init methods


Expand Down Expand Up @@ -83,9 +85,9 @@ Known Issues

Here are some current limitations in OLGhostAlertView:

- The view should be added as a subview of the key window, but it's not ([#1](https://github.com/ondalabs/OLGhostAlertView/issues/1))
- Adding an OLGhostAlertView while displaying a keyboard will cause it to be placed under the keyboard ([#3](https://github.com/ondalabs/OLGhostAlertView/issues/3)). This can be worked around using the `position` property.
Another way to go around this is described on leberwurstsaft's [comment on the issue](https://github.com/ondalabs/OLGhostAlertView/issues/3#issuecomment-9201846).
- If interacting with a UIScrollView, OLGhostAlertView doesn't `hide` until touch tracking actions are complete ([#7](https://github.com/ondalabs/OLGhostAlertView/issues/7)). A workaround is available on the issue thread.

You can find an up-to-date list with full descriptions and discussion at [the Issues page](https://github.com/ondalabs/OLGhostAlertView/issues).

Expand Down

0 comments on commit 0aa66de

Please sign in to comment.