我希望使用UIAlertView提示来提醒用户一些消息,alerview将在2秒内自动关闭.
我的代码:
IBOutlet UIAlertView *aUIAlertView;
Run Code Online (Sandbox Code Playgroud)
....
@property (retain,nonatomic) IBOutlet UIAlertView *aUIAlertView;
Run Code Online (Sandbox Code Playgroud)
....
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
}
Run Code Online (Sandbox Code Playgroud)
提示计时器,aUIAlertView不是零.但警报仍然显示而不是像我希望的那样关闭.
欢迎任何评论
谢谢
简单地将-release消息发送到对象并不能保证它将被解除分配.事实上,在这种情况下,几乎可以肯定它不会被释放,因为系统当前正在显示它.
计时器触发时要发送的消息是dismissWithClickedButtonIndex:animated : .
| 归档时间: |
|
| 查看次数: |
2079 次 |
| 最近记录: |