Skip to content

Can't present safari view controller inside action handler block #60

@bbehradd

Description

@bbehradd

I want to show a alert view to user and after pushing action button present safari viewController
but it wont present.
if i run same code without action handler block, it works very well.
I think the problem is in action handler block.

id DoLogOutAct = ^(LGAlertView *alertView, NSString *title, NSUInteger index) {
        if(index==0){

            NSURL *url = [[NSURL alloc]initWithString:@"http://google.com"];
    SFSafariViewController *safari = [[SFSafariViewController alloc]initWithURL:url];
    [self presentViewController:safari animated:NO completion:nil];
        }
    };
    [Functions showAllert:NSLocalizedString(@"LogOut", @"") Content:NSLocalizedString(@"AreYouSureExitApp", @"") ContentView:nil Buttons:[NSArray arrayWithObject:NSLocalizedString(@"LogOut", @"")] ArrayAction:DoLogOutAct CancelButton:NSLocalizedString(@"NeverMind", @"") CancelAction:nil];
+(LGAlertView *)showAllert:(NSString *)title Content:(NSString *)msg ContentView:(UIView *)cntview Buttons:(NSArray *)ButtonTitle  ArrayAction:(id)actionsBlock CancelButton:(NSString *)cancelBTN CancelAction:(id)cancelAct{
    
    LGAlertView *alertView = [[LGAlertView alloc] initWithViewAndTitle:title
                                                               message:msg
                                                                 style:LGAlertViewStyleAlert
                                                                  view:cntview
                                                          buttonTitles:ButtonTitle
                                                     cancelButtonTitle:cancelBTN
                                                destructiveButtonTitle:nil
                                                         actionHandler:actionsBlock
                                                         cancelHandler:cancelAct
                                                    destructiveHandler:nil];
    
    [alertView setTitleFont:[UIFont fontWithName:NSLocalizedString(@"DefaultFontBold", @"") size:15]];
    [alertView setButtonsFont:[UIFont fontWithName:NSLocalizedString(@"DefaultFont", @"") size:14]];
    [alertView setButtonsBackgroundColor:[UIColor colorWithHexString:@"eee" withAlpha:.5]];
    [alertView setMessageFont:[UIFont fontWithName:NSLocalizedString(@"DefaultFont", @"") size:14]];
    [alertView setCancelButtonFont:[UIFont fontWithName:NSLocalizedString(@"DefaultFont", @"") size:14]];
    [alertView setCancelButtonBackgroundColor:[UIColor colorWithHexString:@"eee" withAlpha:.5]];
    [alertView showAnimated:YES completionHandler:nil];
    return alertView;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions