I hope to use an UIAlertView prompt to reminder user some messages, the alerview will be closed automatically in 2 seconds.
my codes:
IBOutlet UIAlertView *aUIAlertView;
....
@property (retain,nonatomic) IBOutlet UIAlertView *aUIAlertView;
....
UIAlertView * alert=[[UIAlertView alloc]
initWithTitle: @"Reminder"
message: @"Message"
delegate:self
cancelButtonTitle:nil
otherButtonTitles:nil, nil];
[NSTimer scheduledTimerWithTimeInterval:2
target:self
selector:@selector(timerFired1:)
userInfo:nil
repeats:NO];
aUIAlertView=alert;
[alert show];
- (void)timerFired1:(NSTimer *)timer {
[aUIAlertView release];//I set the 开发者_开发技巧breakpoint here, aUIAlertView is not nill
}
timer was prompted, aUIAlertView is not nil. but the alertview still displayed rather than was closed as I hoped.
Welcome any comment
Thanks
Simply sending the -release
message to an object does not guarantee that it will be deallocated. In fact, in this case, it's almost certain that it won't be deallocated, since the system is currently displaying it.
The message you want to send when your timer fires is dismissWithClickedButtonIndex:animated:.
精彩评论