Tag: 定时器

NSTimer timerWithTimeInterval:不工作

在我的项目中实现它之前,我用计时器创build了一个testing应用程序。 这是我第一次使用计时器。 但问题是,当我使用[NSTimer timerWithTimeInterval: target: selector: userInfo: repeats: ];实现了计时器[NSTimer timerWithTimeInterval: target: selector: userInfo: repeats: ]; ,它不工作。 这是我的代码,接口: @interface uialertViewController : UIViewController { NSTimer *timer; } -(void)displayAlert; -(void)hideandview; @end 执行: @implementation uialertViewController – (void)viewDidLoad { [self displayAlert]; [super viewDidLoad]; } -(void)displayAlert{ timer = [NSTimer timerWithTimeInterval:1 target:self selector:@selector(hideandview) userInfo:nil repeats:NO]; alert = [[UIAlertView alloc] initWithTitle:@"testing" message:@"hi hi […]