我在我的函數中創建了UIAlertView,問題是它顯示了函數運行時的很多時間,我如何創建if
語句只顯示一次,如果UIAlertView
顯示不是再次顯示。在客觀-C警報視圖顯示許多時間不是一次
- (void)showAlert {
_myAlertView = nil;
_myAlertView = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Call_On_Hold",nil)
message:NSLocalizedString(@"Please_Wait",nil)
delegate:self
cancelButtonTitle:NSLocalizedString(@"Close_call",nil)
otherButtonTitles:nil, nil];
_myAlertView.tag = myAlertViewsTag;
[_myAlertView show];
}
這裏是我的UIAlertView中不斷出現,而不是一個時間的函數。
- (void) trafficTimerRun:(NSTimer*)theTimer
{
++ trafficTimerTicks;
pjmedia_rtcp_stat stat;
if (!get_stream_info([call_id intValue], &stat)) {
return;
}
LogDebug(TAG_SIP, @"Got %d bytes on stream 0 (previous: %d)", stat.rx.bytes, prev_bytes);
if (stat.rx.bytes == prev_bytes) {
if (trafficTimerTicks >= 10) {
// Steve-note: Here we need to show a pop-up message when the call in on hold when the trafficTimerTicks run.
[self showAlert];
LogError(TAG_SIP, @"No traffic received, hanging up");
// [theTimer invalidate];
// broken = YES; Steve note: The call shouldnt broke.
// [self hangup]; Steve note: The call shouldnt hangup.
}
}
}
感謝先進。
方-note:'UIAlertView'不推薦使用,而是使用'UIAlertController'。 –