代碼爲ios
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"" message:@"感謝你對咱們提出的意見或建議,你的支持就是咱們進步的動力!" delegate:self cancelButtonTitle:@"我知道了" otherButtonTitles:nil, nil]; [alert show]; -(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{ if (buttonIndex==0) { [self backForward]; } }
效果如圖動畫
這是由於alertView的動畫和鍵盤動畫起衝突了
解決方法分爲兩種
①用UIAlertController,適用於ios8之後
②若仍是想用UIAlertView,那麼能夠用以下方法spa
alertview show的時候寫個主線程延遲,pop也延遲線程
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"" message:@"感謝你對咱們提出的意見或建議,你的支持就是咱們進步的動力!" delegate:self cancelButtonTitle:@"我知道了" otherButtonTitles:nil, nil]; dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.4f * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ [alert show]; });
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{ if (buttonIndex==0) { [self performSelector:@selector(backForward) withObject:nil afterDelay:0.25f]; } }
好了的效果以下code