質問編集履歴
3
ソースコード改変
test
CHANGED
File without changes
|
test
CHANGED
@@ -86,7 +86,7 @@
|
|
86
86
|
|
87
87
|
|
88
88
|
|
89
|
-
@IBAction func buttonTapped(
|
89
|
+
@IBAction func buttonTapped(sender: AnyObject) {
|
90
90
|
|
91
91
|
let alertController = UIAlertController(title: "新しくリストを追加", message: "項目を入力して下さい。", preferredStyle: .Alert)
|
92
92
|
|
2
ソースの改変
test
CHANGED
File without changes
|
test
CHANGED
@@ -120,7 +120,7 @@
|
|
120
120
|
|
121
121
|
text.tag = 0
|
122
122
|
|
123
|
-
text.placeholder = "
|
123
|
+
text.placeholder = "リスト名を記入"
|
124
124
|
|
125
125
|
})
|
126
126
|
|
1
修正前のソースコードを記入してしまったので、変更
test
CHANGED
File without changes
|
test
CHANGED
@@ -22,59 +22,137 @@
|
|
22
22
|
|
23
23
|
```
|
24
24
|
|
25
|
-
let alert:UIAlertController = UIAlertController(title:"新しくリストを追加",
|
26
|
-
|
27
|
-
message: "項目を入力してください。",
|
28
|
-
|
29
|
-
|
25
|
+
import UIKit
|
30
26
|
|
31
27
|
|
32
28
|
|
33
|
-
|
29
|
+
class ViewController: UIViewController, UIPopoverPresentationControllerDelegate {
|
34
30
|
|
35
|
-
|
31
|
+
|
36
32
|
|
37
|
-
|
33
|
+
var goalArray: [String] = []
|
38
34
|
|
39
|
-
|
35
|
+
@IBOutlet weak var goalTable: UITableView!
|
40
36
|
|
37
|
+
var toolBar: UIToolbar!
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
override func viewDidLoad() {
|
42
|
+
|
43
|
+
super.viewDidLoad()
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
toolBar = UIToolbar()
|
48
|
+
|
49
|
+
toolBar.sizeToFit()
|
50
|
+
|
51
|
+
let toolBarButton = UIBarButtonItem(title: "Done", style: .Plain, target: self, action: "doneButton")
|
52
|
+
|
53
|
+
toolBar.items = [toolBarButton]
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
}
|
58
|
+
|
59
|
+
override func didReceiveMemoryWarning() {
|
60
|
+
|
61
|
+
super.didReceiveMemoryWarning()
|
62
|
+
|
63
|
+
}
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
func tableView(tableView: UITableView, numberOfRowsInSection section: Int)->Int {
|
68
|
+
|
69
|
+
return goalArray.count
|
70
|
+
|
71
|
+
}
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
func tableView(tableView: UITableView, cellForAtIndexPath indexpath: NSIndexPath)->UITableViewCell {
|
76
|
+
|
77
|
+
let cell: UITableViewCell = UITableViewCell(style: UITableViewCellStyle.Value1, reuseIdentifier: "Cell")
|
78
|
+
|
79
|
+
|
80
|
+
|
81
|
+
cell.textLabel?.text = goalArray[indexpath.row]
|
82
|
+
|
83
|
+
return cell
|
84
|
+
|
85
|
+
}
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
@IBAction func buttonTapped(var sender: AnyObject) {
|
90
|
+
|
91
|
+
let alertController = UIAlertController(title: "新しくリストを追加", message: "項目を入力して下さい。", preferredStyle: .Alert)
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
let cancelAction = UIAlertAction(title: "Cancel", style: .Default){
|
96
|
+
|
41
|
-
|
97
|
+
action in NSLog("Cancel")
|
98
|
+
|
99
|
+
}
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
let otherAction = UIAlertAction(title: "Done", style: .Default){
|
104
|
+
|
105
|
+
action in NSLog("Done")
|
106
|
+
|
107
|
+
}
|
108
|
+
|
109
|
+
|
110
|
+
|
111
|
+
alertController.addAction(cancelAction)
|
112
|
+
|
113
|
+
alertController.addAction(otherAction)
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
//textFieldの追加
|
118
|
+
|
119
|
+
alertController.addTextFieldWithConfigurationHandler({(text: UITextField!) -> Void in
|
120
|
+
|
121
|
+
text.tag = 0
|
122
|
+
|
123
|
+
text.placeholder = "目標を追加"
|
42
124
|
|
43
125
|
})
|
44
126
|
|
45
|
-
|
127
|
+
|
46
128
|
|
47
|
-
|
129
|
+
|
48
130
|
|
49
|
-
|
131
|
+
alertController.addTextFieldWithConfigurationHandler({(text: UITextField!) -> Void in
|
50
132
|
|
51
|
-
|
133
|
+
|
52
134
|
|
135
|
+
text.tag = 1
|
136
|
+
|
53
|
-
|
137
|
+
text.placeholder = "期限を設定(必須)"
|
54
138
|
|
55
139
|
})
|
56
140
|
|
57
|
-
alert.addAction(cancelAction)
|
58
|
-
|
59
|
-
alert.addAction(defaultAction)
|
60
141
|
|
61
142
|
|
143
|
+
|
62
144
|
|
63
|
-
|
145
|
+
|
64
146
|
|
65
|
-
|
147
|
+
presentViewController(alertController, animated: true, completion: nil)
|
66
148
|
|
67
|
-
|
149
|
+
}
|
68
150
|
|
69
|
-
|
151
|
+
|
70
152
|
|
71
|
-
|
153
|
+
}
|
72
154
|
|
73
|
-
textField.placeHolder = "期限を入力"
|
74
155
|
|
75
|
-
})
|
76
|
-
|
77
|
-
presentViewController(alert, animated: true, completion: nil)
|
78
156
|
|
79
157
|
```
|
80
158
|
|