質問編集履歴
2
修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -23,93 +23,3 @@
|
|
23
23
|
|
24
24
|
|
25
25
|
よろしくお願いします。
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
/////////////////
|
30
|
-
|
31
|
-
アルバムに追加する画像取得
|
32
|
-
|
33
|
-
```swift
|
34
|
-
|
35
|
-
let pickerController = DKImagePickerController()
|
36
|
-
|
37
|
-
pickerController.didSelectAssets = { (assets: [DKAsset]) in
|
38
|
-
|
39
|
-
self.assetCount = assets.count
|
40
|
-
|
41
|
-
for asset in assets {
|
42
|
-
|
43
|
-
asset.fetchFullScreenImage(completeBlock: { (image, info) in
|
44
|
-
|
45
|
-
//アルバムに保存
|
46
|
-
|
47
|
-
setAlbum(albumTitle: self.myAlbumCollection[index].localizedTitle!, savingImage: image!)
|
48
|
-
|
49
|
-
})
|
50
|
-
|
51
|
-
}
|
52
|
-
|
53
|
-
}
|
54
|
-
|
55
|
-
pickerController.deselectAll()
|
56
|
-
|
57
|
-
controller.present(pickerController, animated: true) {}
|
58
|
-
|
59
|
-
```
|
60
|
-
|
61
|
-
画像をアルバムに追加
|
62
|
-
|
63
|
-
```swift
|
64
|
-
|
65
|
-
let photoManager: PhotoManager = PhotoManager.sharedInstance
|
66
|
-
|
67
|
-
var theAlbum: PHAssetCollection?
|
68
|
-
|
69
|
-
photoManager.getAlbumCollection().enumerateObjects({(object, index, stop) in
|
70
|
-
|
71
|
-
if object.localizedTitle == albumTitle{
|
72
|
-
|
73
|
-
theAlbum = object
|
74
|
-
|
75
|
-
}
|
76
|
-
|
77
|
-
})
|
78
|
-
|
79
|
-
if let _Album = theAlbum {
|
80
|
-
|
81
|
-
PHPhotoLibrary.shared().performChanges({
|
82
|
-
|
83
|
-
let createAssetRequest = PHAssetChangeRequest.creationRequestForAsset(from: savingImage)
|
84
|
-
|
85
|
-
let assetPlaceHolder = createAssetRequest.placeholderForCreatedAsset!
|
86
|
-
|
87
|
-
let albumChangeRequest = PHAssetCollectionChangeRequest(for: _Album)
|
88
|
-
|
89
|
-
let enumeration: NSArray = [assetPlaceHolder]
|
90
|
-
|
91
|
-
albumChangeRequest!.addAssets(enumeration)
|
92
|
-
|
93
|
-
}, completionHandler: nil)
|
94
|
-
|
95
|
-
}
|
96
|
-
|
97
|
-
```
|
98
|
-
|
99
|
-
端末の画像を取得
|
100
|
-
|
101
|
-
```swift
|
102
|
-
|
103
|
-
let photoManager: PhotoManager = PhotoManager.sharedInstance
|
104
|
-
|
105
|
-
let assets: PHFetchResult = PHAsset.fetchAssets(with: .image, options: nil)
|
106
|
-
|
107
|
-
assets.enumerateObjects { (asset, index, stop) -> Void in
|
108
|
-
|
109
|
-
photoManager.photoAssets.append(asset as PHAsset)
|
110
|
-
|
111
|
-
}
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
```
|
1
コードを追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -23,3 +23,93 @@
|
|
23
23
|
|
24
24
|
|
25
25
|
よろしくお願いします。
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
/////////////////
|
30
|
+
|
31
|
+
アルバムに追加する画像取得
|
32
|
+
|
33
|
+
```swift
|
34
|
+
|
35
|
+
let pickerController = DKImagePickerController()
|
36
|
+
|
37
|
+
pickerController.didSelectAssets = { (assets: [DKAsset]) in
|
38
|
+
|
39
|
+
self.assetCount = assets.count
|
40
|
+
|
41
|
+
for asset in assets {
|
42
|
+
|
43
|
+
asset.fetchFullScreenImage(completeBlock: { (image, info) in
|
44
|
+
|
45
|
+
//アルバムに保存
|
46
|
+
|
47
|
+
setAlbum(albumTitle: self.myAlbumCollection[index].localizedTitle!, savingImage: image!)
|
48
|
+
|
49
|
+
})
|
50
|
+
|
51
|
+
}
|
52
|
+
|
53
|
+
}
|
54
|
+
|
55
|
+
pickerController.deselectAll()
|
56
|
+
|
57
|
+
controller.present(pickerController, animated: true) {}
|
58
|
+
|
59
|
+
```
|
60
|
+
|
61
|
+
画像をアルバムに追加
|
62
|
+
|
63
|
+
```swift
|
64
|
+
|
65
|
+
let photoManager: PhotoManager = PhotoManager.sharedInstance
|
66
|
+
|
67
|
+
var theAlbum: PHAssetCollection?
|
68
|
+
|
69
|
+
photoManager.getAlbumCollection().enumerateObjects({(object, index, stop) in
|
70
|
+
|
71
|
+
if object.localizedTitle == albumTitle{
|
72
|
+
|
73
|
+
theAlbum = object
|
74
|
+
|
75
|
+
}
|
76
|
+
|
77
|
+
})
|
78
|
+
|
79
|
+
if let _Album = theAlbum {
|
80
|
+
|
81
|
+
PHPhotoLibrary.shared().performChanges({
|
82
|
+
|
83
|
+
let createAssetRequest = PHAssetChangeRequest.creationRequestForAsset(from: savingImage)
|
84
|
+
|
85
|
+
let assetPlaceHolder = createAssetRequest.placeholderForCreatedAsset!
|
86
|
+
|
87
|
+
let albumChangeRequest = PHAssetCollectionChangeRequest(for: _Album)
|
88
|
+
|
89
|
+
let enumeration: NSArray = [assetPlaceHolder]
|
90
|
+
|
91
|
+
albumChangeRequest!.addAssets(enumeration)
|
92
|
+
|
93
|
+
}, completionHandler: nil)
|
94
|
+
|
95
|
+
}
|
96
|
+
|
97
|
+
```
|
98
|
+
|
99
|
+
端末の画像を取得
|
100
|
+
|
101
|
+
```swift
|
102
|
+
|
103
|
+
let photoManager: PhotoManager = PhotoManager.sharedInstance
|
104
|
+
|
105
|
+
let assets: PHFetchResult = PHAsset.fetchAssets(with: .image, options: nil)
|
106
|
+
|
107
|
+
assets.enumerateObjects { (asset, index, stop) -> Void in
|
108
|
+
|
109
|
+
photoManager.photoAssets.append(asset as PHAsset)
|
110
|
+
|
111
|
+
}
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
```
|