TSAlertView not responding to delegate?
TSAlertView is TomSwift's https://github.com/TomSwift/TSAlertView/ solution to present modal views that look like UIAlertView but fully customizable. Good work!
However I fail to respond to button press in the modal dialog. 开发者_StackOverflowI set up my viewcontroller as delegate, but there is simply no reaction.
In my own ViewController I write
@interface MyViewController : UIViewController <TSAlertViewDelegate> {
and then I implement
-(void) alertView: (TSAlertView *) alertView didDismissWithButtonIndex: (NSInteger) buttonIndex {
NSLog(@"inside");
}
but it never gets called. It seems like
[self.delegate alertView: self didDismissWithButtonIndex: buttonIndex ];
in TSAlertView.m has no effect.
Also there is no code about this in the Demo. Anybody ever looked at TSAlertView? Figured out how to be delegate for the buttons? Thanks!
TSAlertView
works pretty much the same way as a normal UIAlertView
. Are you sure you're setting the delegate?
Here's a sample code on how I was using it, with all the delegate methods getting called as expected:
TSAlertView *aView = [[TSAlertView alloc] initWithTitle:@"Title" message:@"Message" delegate:self cancelButtonTitle:nil otherButtonTitles:@"Yes", @"No", nil];
// <customize alertview>
[aView show];
[aView release];
You can add a breakpoint in - (void) dismissWithClickedButtonIndex: (NSInteger)buttonIndex animated: (BOOL) animated
(in TSAlertView.m
) and see what goes wrong and check if the delegate was set correctly.
精彩评论