TomSwift/TSAlertView

Delegate not responding?

Closed this issue · 1 comments

In my own ViewController I write

@interface MyViewController : UIViewController <TSAlertViewDelegate> {

and then I implement

  • (void) alertView: (TSAlertView *) alertView didDismissWithButtonIndex: (NSInteger) buttonIndex
    {
    NSLog(@"inside");
    }

but there is no reaction. It seems like

[self.delegate alertView: self didDismissWithButtonIndex: buttonIndex ];
in TSAlertView.m has no effect.

how to respond to button press? Also there is no code about this in the Demo. Thanks!

After some more code examination I figured it out, I need to set the delegate myself (just like with UIAlertView actually).

Example:

TSAlertView* av = [[[TSAlertView alloc] init] autorelease];
av.title = @"Alert Title";
av.message = @"Very important message.";
[av addButtonWithTitle: [NSString stringWithFormat: @"OK"]];
av.delegate = self;
[av show];