Я хотел знать, в порядке ли следующий код или нет. Я пытаюсь автоматически отключить alertView через 2 секунды (и без каких-либо кнопок в alertView) из метода timedAlert.
//this is in another method
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil message:@"Login successful." delegate:self cancelButtonTitle:nil otherButtonTitles:nil];
[alert show];
[alert release];
[self timedAlert];
}
-(void)timedAlert
{
[self performSelector:@selector(dismissAlert:) withObject:alert afterDelay:2];
}
-(void)dismissAlert:(UIAlertView *) alertView
{
[alertView dismissWithClickedButtonIndex:nil animated:YES];
}
Если параметр cancelButton alertView имеет значение «nil», как будет «[alertView dismissWithClickedButtonIndex: 0 animated: YES];» вещь работает ??? Я пытался сделать cancelButton "ноль", и это сработало, но не могу понять, как ....
P.S: я вызываю метод timedAlert из другого
Любая помощь приветствуется! Спасибо!