MBProgressHUD的提示很快就消失了
阿新 • • 發佈:2019-01-05
我記錄一下我的問題,[MBProgressHUD showMessage:@"您的賬戶在其他手機上登入,請重新登入"];
我是這樣寫的,本身這樣寫是沒有問題的嗎,在其它地方顯示也都正常,是過了2秒後消失的
但是我放的下邊這裡後,發現立馬就消失了。我判斷是UIAlerview的事件引起的,所以就加了延遲。
#pragma mark - UIAlertViewDelegate - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex { if (buttonIndex == 1 && alertView.tag == 101) { [MBProgressHUD showMessage:@"您的賬戶在其他手機上登入,請重新登入"]; }else if (alertView.tag == 104) { [self.navigationController popViewControllerAnimated:YES]; } }
</pre><pre>
在貼一下我修改後的程式碼
#pragma mark - UIAlertViewDelegate - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex { if (buttonIndex == 1 && alertView.tag == 101) { dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ [MBProgressHUD showMessage:@"您的賬戶在其他手機上登入,請重新登入"]; }); }else if (alertView.tag == 104) { [self.navigationController popViewControllerAnimated:YES]; } }