Skip to content

Commit

Permalink
Fixing issue Grouper#186
Browse files Browse the repository at this point in the history
  • Loading branch information
somedev committed Jun 5, 2015
1 parent 7d7e2c7 commit ec0f14d
Showing 1 changed file with 30 additions and 13 deletions.
43 changes: 30 additions & 13 deletions Classes/ios/FUIAlertView.m
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,20 @@ + (void)initialize {
}
}

- (id)initWithTitle:(NSString *)title
message:(NSString *)message
delegate:(id<FUIAlertViewDelegate>)delegate
cancelButtonTitle:(NSString *)cancelButtonTitle
otherButtonTitles:(NSString *)otherButtonTitles, ... {
self = [super initWithFrame:CGRectZero];
if (self) {
self.title = title;
self.message = message;
self.delegate = delegate;
- (id)init
{
return [self initWithFrame:CGRectZero];
}

- (id)initWithCoder:(NSCoder *)aDecoder
{
return [self initWithFrame:CGRectZero];
}

- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
self.textFields = [@[] mutableCopy];

// This mask is set to force lay out of subviews when superview's bounds change
Expand Down Expand Up @@ -86,9 +89,23 @@ - (id)initWithTitle:(NSString *)title
[secureTextField setTextAlignment:NSTextAlignmentCenter];
[self.textFields addObject:secureTextField];
[alertContentContainer addSubview:secureTextField];

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow) name:UIKeyboardWillShowNotification object:nil];
}
return self;
}

- (id)initWithTitle:(NSString *)title
message:(NSString *)message
delegate:(id<FUIAlertViewDelegate>)delegate
cancelButtonTitle:(NSString *)cancelButtonTitle
otherButtonTitles:(NSString *)otherButtonTitles, ... {
self = [self initWithFrame:CGRectZero];
if (self) {
self.title = title;
self.message = message;
self.delegate = delegate;

if (cancelButtonTitle) {
[self addButtonWithTitle:cancelButtonTitle];
[self setHasCancelButton:YES];
Expand Down Expand Up @@ -148,7 +165,7 @@ - (void) layoutSubviews {
[self.textFields[0] setFrame:(CGRect){{0, self.messageLabel.frame.origin.y + self.messageLabel.frame.size.height + 10},{self.alertContentContainer.frame.size.width, 40}}];
[self.textFields[1] setFrame:(CGRect){{0, ((FUITextField*)self.textFields[0]).frame.origin.y + ((FUITextField*)self.textFields[0]).frame.size.height + 5},{self.alertContentContainer.frame.size.width, 40}}];
}

__block CGFloat startingButtonY = self.alertContentContainer.frame.size.height - [self totalButtonHeight];
[self.buttons enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
UIButton *button = obj;
Expand Down Expand Up @@ -247,7 +264,7 @@ - (NSInteger) numberOfButtons {
- (void)show {
self.alertContainer.alpha = 0;
self.alertContainer.transform = CGAffineTransformMakeScale(1.3, 1.3);
UIViewController *topController = [UIApplication sharedApplication].keyWindow.rootViewController;
UIViewController *topController = [[[[UIApplication sharedApplication] windows] firstObject] rootViewController];

while (topController.presentedViewController && !topController.presentedViewController.isBeingDismissed) {
topController = topController.presentedViewController;
Expand Down

0 comments on commit ec0f14d

Please sign in to comment.