Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

main thread blocking #24

Open
kaich opened this issue May 23, 2014 · 4 comments
Open

main thread blocking #24

kaich opened this issue May 23, 2014 · 4 comments

Comments

@kaich
Copy link

kaich commented May 23, 2014

when i use it like this,
CXAlertView * alert=[[CXAlertView alloc] initWithTitle:@"warning" message:message cancelButtonTitle:@"cancel"];
[alert addButtonWithTitle:@"continue" type:CXAlertViewButtonTypeDefault handler:^(CXAlertView *alertView, CXAlertButtonItem *button) {
CXAlertView * secondeAlertView=[[CXAlertView alloc] initWithTitle:@"XX" message:@"xxxxxxxxxxxx" cancelButtonTitle:@"sure"];
[secondeAlertView show];
[alertView dismiss];
}];

when i click 'sure' button , the main thread is blocking. i can't touch my view any more!
can you fix the bug ?

@kaich
Copy link
Author

kaich commented May 23, 2014

when i add a time delay, it works fine.
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[alertView dismiss];
});

I am not find the real reason . but hope you fix the bug!

@ChrisXu
Copy link
Owner

ChrisXu commented May 30, 2014

Thanks, I will fix it ASAP.

@jlubeck
Copy link

jlubeck commented Aug 29, 2014

Were you able to fix the bug?? I'm having a lot of problems with this... The dispatch_after method seemed to work, but now I'm getting double alertviews to show for a second before the first one disappears...

@renanstig
Copy link

@jlubeck I found a workaround for this bug.

I instantiated my alert view inside a dispatch_after method. See below:

dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(NSEC_PER_SEC)), dispatch_get_main_queue(), ^{

    NSString *showmessage = [[NSString alloc] init];
    showmessage = [_defaults objectForKey:@"activatedFenceMessage"];
    if (![showmessage isEqualToString:@"1"]) {

        UIView *customAlertView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 260, 199)];

        UIImageView *ivFunc = [[UIImageView alloc] initWithFrame:CGRectMake(57, 8, 146, 88)];
        [ivFunc setImage:[UIImage imageNamed:@"apresentacao_cerca_criada"]];
        [ivFunc setContentMode:UIViewContentModeScaleAspectFit];
        [customAlertView addSubview:ivFunc];
        UILabel *mensagem = [[UILabel alloc] initWithFrame:CGRectMake(8, 108, 250, 53)];
        [mensagem setFont:[UIFont systemFontOfSize:11]];
        [mensagem setLineBreakMode:NSLineBreakByWordWrapping];
        [mensagem setNumberOfLines:6];
        [mensagem setTextAlignment:NSTextAlignmentCenter];



        mensagem.text = activatedFence;
        [customAlertView addSubview:mensagem];



        CXAlertView *alertViewMe = [[CXAlertView alloc] initWithTitle:fenceTitle contentView:customAlertView  cancelButtonTitle:nil];

        // This is a demo for multiple line of title.
        [alertViewMe addButtonWithTitle:multiLineMessageAcceptedText
                                   type:CXAlertViewButtonTypeDefault
                                handler:^(CXAlertView *alertView2, CXAlertButtonItem *button) {
                                    [_defaults setObject:@"0" forKey:@"activatedFenceMessage"];


                                    [alertView2 dismiss];



                                }];

        [alertViewMe addButtonWithTitle:multiLineMessageCancelText
                                   type:CXAlertViewButtonTypeCancel
                                handler:^(CXAlertView *alertView2, CXAlertButtonItem *button) {
                                    [_defaults setObject:@"1" forKey:@"activatedFenceMessage"];

                                    [alertView2 dismiss];



                                }];

        [alertViewMe show];
    }
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants