質問編集履歴
3
ソースコード改変
title
CHANGED
File without changes
|
body
CHANGED
@@ -42,7 +42,7 @@
|
|
42
42
|
return cell
|
43
43
|
}
|
44
44
|
|
45
|
-
@IBAction func buttonTapped(
|
45
|
+
@IBAction func buttonTapped(sender: AnyObject) {
|
46
46
|
let alertController = UIAlertController(title: "新しくリストを追加", message: "項目を入力して下さい。", preferredStyle: .Alert)
|
47
47
|
|
48
48
|
let cancelAction = UIAlertAction(title: "Cancel", style: .Default){
|
2
ソースの改変
title
CHANGED
File without changes
|
body
CHANGED
@@ -59,7 +59,7 @@
|
|
59
59
|
//textFieldの追加
|
60
60
|
alertController.addTextFieldWithConfigurationHandler({(text: UITextField!) -> Void in
|
61
61
|
text.tag = 0
|
62
|
-
text.placeholder = "
|
62
|
+
text.placeholder = "リスト名を記入"
|
63
63
|
})
|
64
64
|
|
65
65
|
|
1
修正前のソースコードを記入してしまったので、変更
title
CHANGED
File without changes
|
body
CHANGED
@@ -10,33 +10,72 @@
|
|
10
10
|
|
11
11
|
###ソースコード
|
12
12
|
```
|
13
|
-
let alert:UIAlertController = UIAlertController(title:"新しくリストを追加",
|
14
|
-
message: "項目を入力してください。",
|
15
|
-
|
13
|
+
import UIKit
|
16
14
|
|
15
|
+
class ViewController: UIViewController, UIPopoverPresentationControllerDelegate {
|
16
|
+
|
17
|
+
var goalArray: [String] = []
|
18
|
+
@IBOutlet weak var goalTable: UITableView!
|
19
|
+
var toolBar: UIToolbar!
|
20
|
+
|
21
|
+
override func viewDidLoad() {
|
22
|
+
super.viewDidLoad()
|
23
|
+
|
24
|
+
toolBar = UIToolbar()
|
25
|
+
toolBar.sizeToFit()
|
26
|
+
let toolBarButton = UIBarButtonItem(title: "Done", style: .Plain, target: self, action: "doneButton")
|
27
|
+
toolBar.items = [toolBarButton]
|
28
|
+
|
29
|
+
}
|
30
|
+
override func didReceiveMemoryWarning() {
|
31
|
+
super.didReceiveMemoryWarning()
|
32
|
+
}
|
33
|
+
|
34
|
+
func tableView(tableView: UITableView, numberOfRowsInSection section: Int)->Int {
|
35
|
+
return goalArray.count
|
36
|
+
}
|
37
|
+
|
38
|
+
func tableView(tableView: UITableView, cellForAtIndexPath indexpath: NSIndexPath)->UITableViewCell {
|
39
|
+
let cell: UITableViewCell = UITableViewCell(style: UITableViewCellStyle.Value1, reuseIdentifier: "Cell")
|
40
|
+
|
41
|
+
cell.textLabel?.text = goalArray[indexpath.row]
|
42
|
+
return cell
|
43
|
+
}
|
44
|
+
|
45
|
+
@IBAction func buttonTapped(var sender: AnyObject) {
|
46
|
+
let alertController = UIAlertController(title: "新しくリストを追加", message: "項目を入力して下さい。", preferredStyle: .Alert)
|
47
|
+
|
17
|
-
let cancelAction
|
48
|
+
let cancelAction = UIAlertAction(title: "Cancel", style: .Default){
|
18
|
-
style: UIAlertActionStyle.Cancel,
|
19
|
-
handler:{
|
20
|
-
(action:UIAlertAction!) -> Void in
|
21
|
-
|
49
|
+
action in NSLog("Cancel")
|
50
|
+
}
|
51
|
+
|
52
|
+
let otherAction = UIAlertAction(title: "Done", style: .Default){
|
53
|
+
action in NSLog("Done")
|
54
|
+
}
|
55
|
+
|
56
|
+
alertController.addAction(cancelAction)
|
57
|
+
alertController.addAction(otherAction)
|
58
|
+
|
59
|
+
//textFieldの追加
|
60
|
+
alertController.addTextFieldWithConfigurationHandler({(text: UITextField!) -> Void in
|
61
|
+
text.tag = 0
|
62
|
+
text.placeholder = "目標を追加"
|
22
63
|
})
|
64
|
+
|
65
|
+
|
23
|
-
|
66
|
+
alertController.addTextFieldWithConfigurationHandler({(text: UITextField!) -> Void in
|
67
|
+
|
68
|
+
text.tag = 1
|
24
|
-
|
69
|
+
text.placeholder = "期限を設定(必須)"
|
25
|
-
handler:{
|
26
|
-
(action:UIAlertAction!) -> Void in
|
27
|
-
print("OK")
|
28
70
|
})
|
29
|
-
alert.addAction(cancelAction)
|
30
|
-
alert.addAction(defaultAction)
|
31
71
|
|
32
|
-
|
72
|
+
|
33
|
-
|
73
|
+
|
34
|
-
textField.placeHolder = "リスト名を入力"
|
35
|
-
})
|
36
|
-
alert.addTextFieldWithConfigurationHandler({(text:UITextField!) -> Void in
|
37
|
-
textField.placeHolder = "期限を入力"
|
38
|
-
})
|
39
|
-
presentViewController(
|
74
|
+
presentViewController(alertController, animated: true, completion: nil)
|
75
|
+
}
|
76
|
+
|
77
|
+
}
|
78
|
+
|
40
79
|
```
|
41
80
|
|
42
81
|
これまでに、defaultAction内に、textDidEndEditingメソッドを追加してみたりなどしてみたのですが、
|