質問編集履歴

1

自己解決しました

2016/04/24 09:40

投稿

yuxa
yuxa

スコア12

test CHANGED
File without changes
test CHANGED
@@ -1,235 +1,7 @@
1
- お世話になっておりま
1
+ 申し訳ありません
2
2
 
3
- 今回tableviewのcelをクリックした際のメソッドが呼び出されず
3
+ 自己解決まし
4
4
 
5
- 苦戦ています
5
+ ただの宣言ミスで
6
6
 
7
- ```swift
8
-
9
- tableView(table: UITableView, didDeselectRowAtIndexPath indexPath: NSIndexPath)
10
-
11
- ```
12
-
13
- を呼び出したいのですが全く呼び出されません。
14
-
15
- 検索してみたところ
16
-
17
- table.delegate = self
18
-
19
- table.dataSource = self
20
-
21
- やstoryboardの設定のselection
22
-
23
- など見てもちゃんとしています
7
+ 関数名や引数名には気つけます
24
-
25
-
26
-
27
- どうか改善させるのにお力添えください。
28
-
29
- コードは関係ないところは省略しております。
30
-
31
- ```swift
32
-
33
-
34
-
35
- @IBOutlet weak var table: UITableView!
36
-
37
- override func viewDidLoad() {
38
-
39
- super.viewDidLoad()
40
-
41
- table.delegate = self
42
-
43
- table.dataSource = self
44
-
45
- }
46
-
47
- func tableView(table: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
48
-
49
- let appDelegate:AppDelegate = UIApplication.sharedApplication().delegate as! AppDelegate
50
-
51
- let cell = table.dequeueReusableCellWithIdentifier("tableview_s", forIndexPath: indexPath)
52
-
53
-
54
-
55
- if appDelegate.URLstr == nil{
56
-
57
- return cell
58
-
59
- }else{
60
-
61
- //インスタンス生成
62
-
63
- let imgview = table.viewWithTag(1) as! UIImageView
64
-
65
- let label_t = table.viewWithTag(2) as! UILabel
66
-
67
- let label_s = table.viewWithTag(3) as! UILabel
68
-
69
- let label_w = table.viewWithTag(4) as! UILabel
70
-
71
- //URLstr = BaseURL+"&latitude="+useLoction[0].description+"&longitude="+useLoction[1].description+"&range="+rangenum.description
72
-
73
- let URLns = NSURL(string:appDelegate.URLstr!)
74
-
75
-
76
-
77
-
78
-
79
- var json:NSDictionary!
80
-
81
- let jsonData :NSData = NSData(contentsOfURL: URLns!)!
82
-
83
- do {
84
-
85
- print("\(URLstr)")
86
-
87
- json = try NSJSONSerialization.JSONObjectWithData(jsonData, options: .MutableContainers) as! NSDictionary
88
-
89
-
90
-
91
- } catch {
92
-
93
- print("error code -1")
94
-
95
- }
96
-
97
-
98
-
99
- rest = json.objectForKey("rest") as! NSArray //restdata整理
100
-
101
-
102
-
103
-
104
-
105
- var access:NSDictionary!
106
-
107
- var pic:NSDictionary! = nil
108
-
109
-
110
-
111
-
112
-
113
- print(rest[indexPath.row].objectForKey("name") as! NSString)
114
-
115
- label_t.text = rest[indexPath.row].objectForKey("name") as? String
116
-
117
- send_title.append((rest[indexPath.row].objectForKey("name") as? String)!)
118
-
119
- access = rest[indexPath.row].objectForKey("access") as! NSDictionary
120
-
121
- if let accessdata_s = access["station"] as? NSString where accessdata_s != "{\n}" {
122
-
123
- label_s.text = accessdata_s as String
124
-
125
- }else{
126
-
127
- //print("NotFound")
128
-
129
- label_s.text = "NotFound"
130
-
131
- }
132
-
133
- if let accessdata_w = access["walk"] as? NSString where accessdata_w != "{\n}" {
134
-
135
- label_w.text = accessdata_w as String
136
-
137
- }else{
138
-
139
- //print("NotFound")
140
-
141
- label_w.text = "NotFound"
142
-
143
- }
144
-
145
- pic = rest[indexPath.row].objectForKey("image_url") as! NSDictionary
146
-
147
- if let picdata = pic["shop_image1"] as? NSString where picdata != "{\n}" {
148
-
149
- let url = NSURL(string:picdata as String)
150
-
151
- let req = NSURLRequest(URL:url!)
152
-
153
-
154
-
155
- NSURLConnection.sendAsynchronousRequest(req, queue:NSOperationQueue.mainQueue()){(res, data, err) in
156
-
157
-
158
-
159
- let image = UIImage(data:data!)
160
-
161
- imgview.image = image
162
-
163
- self.send_pic.append(image!)
164
-
165
- }
166
-
167
- }else {
168
-
169
- //print("NotFound")
170
-
171
- let url = NSURL(string:"http://apicache.gnavi.co.jp/image/rest/b/api_265_65.gif")
172
-
173
- let req = NSURLRequest(URL:url!)
174
-
175
-
176
-
177
- NSURLConnection.sendAsynchronousRequest(req, queue:NSOperationQueue.mainQueue()){(res, data, err) in
178
-
179
-
180
-
181
- let image = UIImage(data:data!)
182
-
183
- imgview.image = image
184
-
185
- self.send_pic.append(image!)
186
-
187
- }
188
-
189
- }
190
-
191
- return cell
192
-
193
- }
194
-
195
- }
196
-
197
-
198
-
199
- func tableView(table: UITableView, didDeselectRowAtIndexPath indexPath: NSIndexPath) {
200
-
201
- selected_num = indexPath.row
202
-
203
- selectedimg = UIImage(named: "\(send_pic[indexPath.row])")
204
-
205
- if selectedimg != nil{
206
-
207
- performSegueWithIdentifier("status", sender: nil)
208
-
209
- }
210
-
211
- }
212
-
213
-
214
-
215
- override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
216
-
217
- if (segue.identifier == "status") {
218
-
219
- //let status_s: status = (segue.destinationViewController as? status)!
220
-
221
- // SubViewController のselectedImgに選択された画像を設定する
222
-
223
- let appDelegate:AppDelegate = UIApplication.sharedApplication().delegate as! AppDelegate
224
-
225
- appDelegate.img = selectedimg
226
-
227
- appDelegate.tit = send_title[selected_num]
228
-
229
- print(appDelegate.tit)
230
-
231
- }
232
-
233
- }
234
-
235
- ```