-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUIAlertView+LamUnique.m
More file actions
65 lines (45 loc) · 1.44 KB
/
UIAlertView+LamUnique.m
File metadata and controls
65 lines (45 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
//
// UIAlertView+LamUnique.m
//
// Created by Nicolas on 27/07/11.
// Copyright 2011 Atelier du mobile. All rights reserved.
//
#import "UIAlertView+LamUnique.h"
#import <objc/runtime.h>
static bool hasCurrentAlertDisplayed;
@implementation UIAlertView (LamUnique)
- (void) unlockAlerts {
hasCurrentAlertDisplayed = FALSE;
//LoggerAlert(5,@"hasCurrentAlertDisplayed=%d", hasCurrentAlertDisplayed);
}
//we can display an alert if :
// - the app is active
// - an alert is not currently displayed
- (BOOL) isAlertDisplayable {
//LoggerAlert(5,@"hasCurrentAlertDisplayed=%d", hasCurrentAlertDisplayed);
if([[UIApplication sharedApplication] applicationState] == UIApplicationStateActive
&& !hasCurrentAlertDisplayed ) {
return TRUE;
}
return FALSE;
}
- (void)showAndLock {
hasCurrentAlertDisplayed = TRUE;
//LoggerAlert(5,@"set hasCurrentAlertDisplayed %d", hasCurrentAlertDisplayed);
[self show];
}
- (void)showIfNotExistingOne {
if ([self isAlertDisplayable]) {
hasCurrentAlertDisplayed = TRUE;
//LoggerAlert(5,@"set hasCurrentAlertDisplayed %d", hasCurrentAlertDisplayed);
[self show];
}
}
- (void)showIfNotExistingOneWithoutLock {
if ([self isAlertDisplayable]) {
hasCurrentAlertDisplayed = TRUE;
//LoggerAlert(5,@"set hasCurrentAlertDisplayed %d", hasCurrentAlertDisplayed);
[self show];
}
}
@end