質問編集履歴
2
詳細を記述
title
CHANGED
@@ -1,1 +1,1 @@
|
|
1
|
-
swiftで、TableViewに
|
1
|
+
swiftで、TableViewに罫線が表示されないため困っています。
|
body
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
質問があります、よろしくお願い申し上げます。
|
2
2
|
|
3
3
|
解決したいこと
|
4
|
+
|
4
5
|
下記のコードでは、アプリに罫線が表示されずに困っています。
|
5
6
|
|
6
7
|

|
@@ -98,82 +99,4 @@
|
|
98
99
|
|
99
100
|
}
|
100
101
|
|
101
|
-
|
102
|
-
|
103
|
-
class ViewController: UIViewController, UITableViewDataSource {
|
104
|
-
|
105
|
-
//tableViewを参照できるようにする
|
106
|
-
@IBOutlet weak var tableView: UITableView!
|
107
|
-
|
108
|
-
//Insert below the tableView IBOutlet
|
109
|
-
var names = [String]()
|
110
|
-
|
111
|
-
//ユーザーのアクションとプログラムを結びつける
|
112
|
-
@IBAction func addName(sender: AnyObject) {
|
113
|
-
|
114
|
-
let alert = UIAlertController(title: "New Name",
|
115
|
-
message: "Add a new name",
|
116
|
-
preferredStyle: .Alert)
|
117
|
-
|
118
|
-
let saveAction = UIAlertAction(title: "Save",
|
119
|
-
style: .Default,
|
120
|
-
handler: { (action:UIAlertAction) -> Void in
|
121
|
-
|
122
|
-
let textField = alert.textFields!.first
|
123
|
-
self.names.append(textField!.text!)
|
124
|
-
self.tableView.reloadData()
|
125
|
-
})
|
126
|
-
|
127
|
-
let cancelAction = UIAlertAction(title: "Cancel",
|
128
|
-
style: .Default) { (action: UIAlertAction) -> Void in
|
129
|
-
}
|
130
|
-
|
131
|
-
alert.addTextFieldWithConfigurationHandler {
|
132
|
-
(textField: UITextField) -> Void in
|
133
|
-
}
|
134
|
-
|
135
|
-
alert.addAction(saveAction)
|
136
|
-
alert.addAction(cancelAction)
|
137
|
-
|
138
|
-
presentViewController(alert,
|
139
|
-
animated: true,
|
140
|
-
completion: nil)
|
141
|
-
}
|
142
|
-
|
143
|
-
//タイトルの設定とCellを毎回再利用する
|
144
|
-
override func viewDidLoad() {
|
145
|
-
super.viewDidLoad()
|
146
|
-
title = "\"The List\""
|
147
|
-
tableView.registerClass(UITableViewCell.self,
|
148
|
-
forCellReuseIdentifier: "Cell")
|
149
|
-
|
150
|
-
}
|
151
|
-
|
152
|
-
//テーブルの中のセクションの数を決める
|
153
|
-
func numberOfSectionsInTableView(tableView: UITableView) -> Int {
|
154
|
-
return 1
|
155
|
-
}
|
156
|
-
|
157
|
-
//UITableViewのData Sourceを決める 変数namesの数を返す。
|
158
|
-
//変数cellに再利用するCellを入れて、Cellに入力された値をnamesに入れて返す。
|
159
|
-
func tableView(tableView: UITableView,
|
160
|
-
numberOfRowsInSection section: Int) -> Int {
|
161
|
-
return names.count
|
162
|
-
}
|
163
|
-
|
164
|
-
func tableView(tableView: UITableView,
|
165
|
-
cellForRowAtIndexPath
|
166
|
-
indexPath: NSIndexPath) -> UITableViewCell {
|
167
|
-
|
168
|
-
let cell =
|
169
|
-
tableView.dequeueReusableCellWithIdentifier("Cell")
|
170
|
-
|
171
|
-
cell!.textLabel!.text = names[indexPath.row]
|
172
|
-
|
173
|
-
return cell!
|
174
|
-
}
|
175
|
-
|
176
|
-
|
177
|
-
}
|
178
|
-
|
179
102
|
```
|
1
変更
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,11 +1,13 @@
|
|
1
1
|
質問があります、よろしくお願い申し上げます。
|
2
2
|
|
3
|
+
解決したいこと
|
3
|
-
下記のコードでは、アプリ
|
4
|
+
下記のコードでは、アプリに罫線が表示されずに困っています。
|
4
5
|
|
5
6
|

|
6
7
|
|
7
|
-
本当は、下記のようにしたいのですが、解決策が見つからないため質問致します。
|
8
8
|
|
9
|
+
理想図
|
10
|
+
|
9
11
|

|
10
12
|
|
11
13
|
よろしくお願い申し上げます。
|
@@ -171,9 +173,7 @@
|
|
171
173
|
return cell!
|
172
174
|
}
|
173
175
|
|
174
|
-
|
176
|
+
|
175
|
-
super.didReceiveMemoryWarning()
|
176
|
-
}
|
177
177
|
}
|
178
178
|
|
179
179
|
```
|