dogo / SCLAlertView

Beautiful animated Alert View. Written in Objective-C
MIT License
3.5k stars 534 forks source link

SCLAlert view not covering Navigation or TabBar #219

Closed ignasibm closed 8 years ago

ignasibm commented 8 years ago

Hello, first of all thanks for your work, SCLAlerts looks awesome! I just wanted to know if there's a way to make the Alert take the "whole screen space" like UIAlertController (or UIAlertView did). As you are going to see in the following screenshot, the Alert itself seems to be centered just ok, in the middle of the screen, but the "shadow view" that appears at the same time than the alert only goes from my navigation bar to my tabbar. Also, navigation bar and tabbar are still functionall when the a SCLAlertView is showing. This is confusing because this didn't happen with UIAlerController o UIAlertView. Any ideas?

Thanks :)

Include the following:

This is the code I used to create the SCLAlertView:

`SCLAlertView *alert = [[SCLAlertView alloc] init]; alert.shouldDismissOnTapOutside = YES; [alert removeTopCircle];

SCLSwitchView *switchView = [alert addSwitchViewWithLabel:NSLocalizedString(@"¿Olvidar Contraseña?",nil).uppercaseString];
switchView.tintColor = [UIColor darkGrayColor];

[alert addButton:NSLocalizedString(@"Cerrar Sesión",nil) actionBlock:^(void) {
    if (switchView.isSelected) {
        //Do whatever
    } 
    [self logOut];
}];

[alert addButton:NSLocalizedString(@"Cancelar",nil) actionBlock:^(void) {
}];

[alert showCustom:self image:[UIImage imageNamed:@"switch"] color:kGreenColor title:NSLocalizedString(@"Cerrar Sesión",nil) subTitle:NSLocalizedString(@"¿Seguro que quieres cerrar sesión?",nil) closeButtonTitle:nil duration:0.0f];

`

Expected Result

Shadowview should cover the whole screen

Actual Result

It doesn't >.<

dogo commented 8 years ago

Hi @ignasibm, this can be done in many ways

Getting the window RootViewController

SCLAlertView *alert = [[SCLAlertView alloc] init];

UIViewController *rootViewController = [[[UIApplication sharedApplication] keyWindow] rootViewController];    

[alert showCustom:rootViewController title:@"Hello World" subTitle:@"This is a more descriptive text." closeButtonTitle:@"Done" duration:0.0f];

or using the navigationController

SCLAlertView *alert = [[SCLAlertView alloc] init];

[alert showCustom:self.navigationController title:@"Hello World" subTitle:@"This is a more descriptive text." closeButtonTitle:@"Done" duration:0.0f];

or creating a new window

SCLAlertView *alert = [[SCLAlertView alloc] initWithNewWindow];

[alert showSuccess:@"Hello World" subTitle:@"This is a more descriptive text." closeButtonTitle:@"Done" duration:0.0f];
ignasibm commented 8 years ago

HI @dogo thank you for your help, it worked!

Some feedback in my particular case. Using the NavController method, the TabBar was still showing over the Alert. It was using the RootViewController method that worked like a charm.

Thanks again :)

dogo commented 8 years ago

Great :D

fukemy commented 6 years ago

great job, thanks you