The disappearance of uialertview actually triggers a dismiss event. Note that removefromsubview does not work. We can use the code to touch a button to make the uialertview disappear automatically.
By setting a timer, you can set how many seconds will automatically disappear.
Code implementation:
-(Void) popalertview {uialertview * alertview = [[uialertview alloc] initwithtitle: @ "tip" message: @ "congratulations, registration successful" delegate: Self cancelbuttontitle: Nil failed: @ "cancel", nil]; self. alertview = alertview; // sets the timer. The timer automatically disappears after 1.5 seconds. [nstimer scheduledtimerwithtimeinterval: 1.5f target: Self selector: @ selector (invalid mdismiss :) userinfo: Nil repeats: No]; [alertview show] ;}- (void) implements mdismiss :( nstimer *) timer {[self. alertview dismisswithclickedbuttonindex: 0 animated: No];}
How to add an automatically disappearing uialertview