質問するログイン新規登録

質問編集履歴

1

コードの修正

2017/02/05 07:38

投稿

mokumoku
mokumoku

スコア46

title CHANGED
File without changes
body CHANGED
@@ -10,13 +10,15 @@
10
10
 
11
11
  ###ソースコード(一部省略)
12
12
  ```ここに言語を入力
13
+ var image: String = ""
14
+ var imageUrl: [URL] = []
15
+ var imageData: [Data] = []
16
+ var count: Int = 0
13
17
 
14
- var imageUrl: [NSURL] = []
15
- var imageData: [NSData]! = []
18
+ image = json["image_path_list"].string!
19
+ imageUrl += [NSURL(string:"画像データのパス" + image) as! URL]
16
- var count1: Int = 0
20
+ print(imageUrl[count],"imageUrl")
17
21
 
18
- imageUrl += [NSURL(string:"画像データのパス")!]
19
-
20
22
  //マーカーのビューを引数のannotationを用いて作成する
21
23
  pin = YMKPinAnnotationView(annotation: annotation, reuseIdentifier: "Pin")
22
24
  //吹き出しに表示するボタンの登録
@@ -25,11 +27,10 @@
25
27
  //pin?.animatesDrop = true
26
28
  rightAccessoryButton.frame = CGRect(x: 0,y: 0,width: 29,height: 29)
27
29
  do {
28
- imageData![count1] = try NSData(contentsOf: imageUrl[count1] as URL)
30
+ imageData += try [Data(contentsOf: (imageUrl[count] as NSURL) as URL)]
29
- rightAccessoryButton.setBackgroundImage(UIImage(named:"\(imageData![count1])"), for: UIControlState.normal)
31
+ rightAccessoryButton.setBackgroundImage(UIImage(named:"\(imageData[count])"), for: UIControlState.normal)
32
+ pin?.rightCalloutAccessoryView = rightAccessoryButton
30
33
  } catch {
31
34
 
32
35
  }
33
-
34
- pin?.rightCalloutAccessoryView = rightAccessoryButton
35
36
  ```