回答編集履歴
2
書き換え
test
CHANGED
@@ -8,56 +8,62 @@
|
|
8
8
|
|
9
9
|
|
10
10
|
|
11
|
-
|
11
|
+
func singleAlert(title:String, message:String, buttonTitle:String){
|
12
12
|
|
13
|
-
|
13
|
+
|
14
14
|
|
15
|
-
|
15
|
+
//iOS8以上
|
16
16
|
|
17
|
-
|
17
|
+
if objc_getClass("UIAlertController") != nil {
|
18
18
|
|
19
|
-
|
19
|
+
let myAlert = UIAlertController(
|
20
20
|
|
21
|
+
title: title,
|
22
|
+
|
23
|
+
message: message,
|
24
|
+
|
21
|
-
|
25
|
+
preferredStyle: .Alert)
|
22
26
|
|
23
27
|
|
24
28
|
|
25
|
-
|
29
|
+
// OKのアクションを作成する.
|
26
30
|
|
27
|
-
|
31
|
+
let OkAction = UIAlertAction(title: buttonTitle, style: .Default) { action in
|
28
32
|
|
29
33
|
|
30
34
|
|
31
|
-
|
35
|
+
}
|
32
36
|
|
33
37
|
|
34
38
|
|
35
|
-
|
39
|
+
// Actionを追加する.
|
36
40
|
|
37
|
-
|
41
|
+
myAlert.addAction(OkAction)
|
38
42
|
|
39
43
|
|
40
44
|
|
41
|
-
|
45
|
+
// UIAlertを発動する.
|
42
46
|
|
43
|
-
|
47
|
+
presentViewController(myAlert, animated: true, completion: nil)
|
44
48
|
|
45
49
|
|
46
50
|
|
47
|
-
|
51
|
+
} else {
|
48
52
|
|
49
|
-
|
53
|
+
//iOS7以下
|
50
54
|
|
51
|
-
|
55
|
+
var alert = UIAlertView()
|
52
56
|
|
53
|
-
|
57
|
+
alert.title = title
|
54
58
|
|
55
|
-
|
59
|
+
alert.message = message
|
56
60
|
|
57
|
-
|
61
|
+
alert.addButtonWithTitle(buttonTitle)
|
58
62
|
|
59
|
-
|
63
|
+
alert.show()
|
60
64
|
|
61
|
-
|
65
|
+
}
|
66
|
+
|
67
|
+
}
|
62
68
|
|
63
69
|
```
|
1
変更
test
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
ios7ではUIAlertViewを使います。
|
2
2
|
|
3
|
-
以下の
|
3
|
+
以下のようにiOS7と8で切り分けて使ってください。
|
4
4
|
|
5
5
|
|
6
6
|
|