Я могу загрузить PHLivephoto с помощью loadTransferable(type: PHLivePhoto.self).
Но мне не удалось загрузить livephoto loadTransferable(type: LivephotoTrasferable.self)
в котором LivephotoTrasferable выглядит следующим образом:
struct LivephotoTrasferable: Transferable {
static var transferRepresentation: some TransferRepresentation {
FileRepresentation(contentType: .livePhoto) { item in
SentTransferredFile(item.url)
} importing: { file in
print("livephoto!")
return Self.init(url: file.file)
}
}
var url: URL
}
Весь фрагмент кода:
struct ContentView: View {
@State private var selection: PhotosPickerItem?
var body: some View {
VStack {
PhotosPicker(selection: $selection) {
Text("Import image")
}
.buttonStyle(.borderedProminent)
.onChange(of: selection) { oldValue, newValue in
if let item = newValue {
self.loadTransferable(item)
self.selection = nil
}
}
}
.padding()
}
func loadTransferable(_ item: PhotosPickerItem) {
Task {
let livephoto = try? await item.loadTransferable(type: PHLivePhoto.self)
let livephoto2 = try? await item.loadTransferable(type: LivephotoTrasferable.self)
print(livephoto != nil, livephoto2 != nil) // true, false
}
}
}
struct LivephotoTrasferable: Transferable {
static var transferRepresentation: some TransferRepresentation {
FileRepresentation(contentType: .livePhoto) { item in
SentTransferredFile(item.url)
} importing: { file in
print("livephoto!")
return Self.init(url: file.file)
}
}
var url: URL
}
Подробнее здесь: https://stackoverflow.com/questions/783 ... ansferable
Как загрузить живое фото из PhotosPickerItem с помощью Transferable ⇐ IOS
Программируем под IOS
-
Anonymous
1714139798
Anonymous
Я могу загрузить PHLivephoto с помощью loadTransferable(type: PHLivePhoto.self).
Но мне не удалось загрузить livephoto loadTransferable(type: LivephotoTrasferable.self)
в котором LivephotoTrasferable выглядит следующим образом:
struct LivephotoTrasferable: Transferable {
static var transferRepresentation: some TransferRepresentation {
FileRepresentation(contentType: .livePhoto) { item in
SentTransferredFile(item.url)
} importing: { file in
print("livephoto!")
return Self.init(url: file.file)
}
}
var url: URL
}
Весь фрагмент кода:
struct ContentView: View {
@State private var selection: PhotosPickerItem?
var body: some View {
VStack {
PhotosPicker(selection: $selection) {
Text("Import image")
}
.buttonStyle(.borderedProminent)
.onChange(of: selection) { oldValue, newValue in
if let item = newValue {
self.loadTransferable(item)
self.selection = nil
}
}
}
.padding()
}
func loadTransferable(_ item: PhotosPickerItem) {
Task {
let livephoto = try? await item.loadTransferable(type: PHLivePhoto.self)
let livephoto2 = try? await item.loadTransferable(type: LivephotoTrasferable.self)
print(livephoto != nil, livephoto2 != nil) // true, false
}
}
}
struct LivephotoTrasferable: Transferable {
static var transferRepresentation: some TransferRepresentation {
FileRepresentation(contentType: .livePhoto) { item in
SentTransferredFile(item.url)
} importing: { file in
print("livephoto!")
return Self.init(url: file.file)
}
}
var url: URL
}
Подробнее здесь: [url]https://stackoverflow.com/questions/78390964/how-to-load-livephoto-from-photospickeritem-with-transferable[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия