wimagguc / ios-custom-alertview

Custom UIAlertView. Continue adding images and UIViews to dialogs in iOS7+
Other
1.66k stars 394 forks source link

Identify what alert view was closed in more comfortable way #2

Closed masterrr closed 11 years ago

masterrr commented 11 years ago

If I have a lot of alert views, I tag them to identify properly in controller delegate method. We need to create more comfortable way to do it (pass a tag in the delegate method, put some methods so users can tag buttons, etc?)

Here is how I do it now

Creating alert view(s)

-(void)makeAlert:(NSIndexPath*)indexPath {
    CustomIOS7AlertView *alertView = [[CustomIOS7AlertView alloc] initWithParentView:self.view];
    alertView.tag = 1;
    [alertView setDelegate:self];
    [alertView show];
}

Detecting that exactly the alert view above was closed

- (IBAction)customIOS7dialogButtonTouchUpInside:(id)sender
{
    NSLog(@"Button at position %d is clicked.", [sender tag]);
    NSLog(@"Alert View Tag: %d", [[[sender superview] superview] tag]);
}
wimagguc commented 11 years ago

Hey, thanks a lot. The next update matches the standard UIAlertView delegate (which has a better solution for this).