wimagguc/ios-custom-alertview

Alertview not showing with init

Closed this issue · 2 comments

I have used exactly the same code given in the demo, just to test how this works, and the alert isn't showing. This is the code:

CustomIOS7AlertView *alertView = [[CustomIOS7AlertView alloc] init];

//It works only when using initwithparentview

// Add some custom content to the alert view
[alertView setContainerView:[self createDemoView]];

// Modify the parameters
[alertView setButtonTitles:[NSMutableArray arrayWithObjects:@"Close1", @"Close2", @"Close3", nil]];
[alertView setDelegate:self];

// You may use a Block, rather than a delegate.
[alertView setOnButtonTouchUpInside:^(CustomIOS7AlertView *alertView, int buttonIndex) {
    NSLog(@"Block: Button at position %d is clicked on alertView %d.", buttonIndex, [alertView tag]);
    [alertView close];
}];

[alertView setUseMotionEffects:true];

// And launch the dialog
[alertView show];

The init is not working, I have used the deprecated version, the one with initWithParentView, and it works just fine.

Are you trying to do this on viewDidLoad? In this case, this issue (and solution) might help:
#26

I create the alertView inside a didSelectRowForIndexPath, I already tried getting the main queue, but didn't work.

I guess I'll keep using initwithparentView.