关于AleartView自动消失的问题,把AleartView声明成属性,定义一个延时方法,让AleratView服从延时方法
@interface ActivityDesController ()
@property(nonatomic,strong) UIAlertView *alert;
@end
延时方法
-(void)performDismiss:(NSTimer *)timer{
[self.alert dismissWithClickedButtonIndex:0 animated:NO];
}
声明点击方法,在实现点击方法中添加AleartView
-(void)clickTheRunButton:(UIBarButtonItem *)button{
if (![WhetherLogin shareWhetherLogin].enter) {
LoginViewController *loginVC = [[LoginViewController alloc]init];
[self.navigationController pushViewController:loginVC animated:YES];
}else{
self.alert = [[UIAlertView alloc]initWithTitle:@"提示" message:@"收藏成功" delegate:self cancelButtonTitle:nil otherButtonTitles:nil, nil];
[NSTimer scheduledTimerWithTimeInterval:1.5f target:self selector:@selector(performDismiss:) userInfo:nil repeats:NO];
[self.alert show];}
}