Post

Replies

Boosts

Views

Activity

AsyncImage in List not working on iOS 16
struct Item: Identifiable { let id: String let url = URL(string: "https://styles.redditmedia.com/t5_j6lc8/styles/communityIcon_9uopq0bazux01.jpg")! } struct Content: View { let model: [Item] = { var model = [Item]() for i in 0 ..< 100 { model.append(.init(id: String(i))) } return model }() var body: some View { List(model) { item in Row(item: item) } } } struct Row: View { let item: Item var body: some View { AsyncImage(url: item.url) } } Running code above with Xcode 14.1 RC on iOS 16.1 Beta simulator, AsyncImage sometimes doesn’t properly show downloaded image but grey rectangle instead when scrolling in list. Is this bug or am I missing something? Thanks
1
2
1.4k
Oct ’22
Apply CIFilter to video then add 2nd track
So I have two videos assets - one for background and one for foreground. What I want to achieve is to apply a CIFilter (ChromaKey) to the foreground video then add the background video so the two overlap. I can do the overlap or applying the filter but I can't put it together. Here is my code for videos overlap. let bgAsset = AVURLAsset(url: URL(fileURLWithPath: Bundle.main.path(forResource: "bg", ofType: "mp4")!)) let fgAsset = AVURLAsset(url: URL(fileURLWithPath: Bundle.main.path(forResource: "fg", ofType: "mp4")!)) let mixComposition = AVMutableComposition() let bgTrack = mixComposition.addMutableTrack(withMediaType: .video, preferredTrackID: kCMPersistentTrackIDInvalid)! let fgTrack = mixComposition.addMutableTrack(withMediaType: .video, preferredTrackID: kCMPersistentTrackIDInvalid)! try! bgTrack.insertTimeRange(CMTimeRange(start: .zero, duration: bgAsset.duration), of: bgAsset.tracks(withMediaType: .video).first!, at: .zero) try! fgTrack.insertTimeRange(CMTimeRange(start: .zero, duration: bgAsset.duration), of: fgAsset.tracks(withMediaType: .video).first!, at: .zero) let mainInstruction = AVMutableVideoCompositionInstruction() mainInstruction.timeRange = CMTimeRange(start: .zero, duration: bgAsset.duration) let firstLayerInstruction = AVMutableVideoCompositionLayerInstruction(assetTrack: bgTrack) let secondLayerInstruction = AVMutableVideoCompositionLayerInstruction(assetTrack: fgTrack) mainInstruction.layerInstructions = [secondLayerInstruction, firstLayerInstruction] let videoComposition = AVMutableVideoComposition() videoComposition.instructions = [mainInstruction] videoComposition.frameDuration = CMTime(value: 1, timescale: 30) videoComposition.renderSize = CGSize(width: 640, height: 480) let url = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0].appendingPathComponent("overlapVideo.mov") let exporter = AVAssetExportSession(asset: mixComposition, presetName: AVAssetExportPresetHighestQuality)! exporter.outputURL = url exporter.videoComposition = videoComposition exporter.outputFileType = .mov exporter.exportAsynchronously { print("finished") } Thanks for any help!
0
0
767
Oct ’20
MacOS SwiftUI List move multiple rows
Hi, I have this simple view in SwiftUI, where it's possible to move a single row and select one or more rows. struct ContentView: View {     @State var selectedItems = Set&lt;Int&gt;()     @State var items = Array(1...10).map({ S(id: $0) })     var body: some View {         List(selection: $selectedItems) {             ForEach(items) { (item) in                 Text(String(item.id))                     .padding()             }             .onMove(perform: { indices, newOffset in                 withAnimation {                     self.items.move(fromOffsets: indices, toOffset: newOffset)                 }             })         }     } } When I select 2 or more rows and try to move them I got this error log: 2020-07-30 10:20:03.035238+0200 list[54240:1678921] [General] There are 2 items on the pasteboard, but 1 drag images. There must be 1 draggingItem per pasteboardItem. 2020-07-30 10:20:03.039250+0200 list[54240:1678921] [General] ( 0   CoreFoundation                      0x00007fff2a8865af __exceptionPreprocess + 242 1   libobjc.A.dylib                     0x00007fff6acb36c4 objc_exception_throw + 48 2   CoreFoundation                      0x00007fff2a886413 +[NSException raise:format:] + 189 3   AppKit                              0x00007fff27a61d80 -[NSDraggingSession(NSInternal) _initWithPasteboard:image:offset:source:] + 243 4   AppKit                              0x00007fff27a617ba -[NSCoreDragManager dragImage:fromWindow:at:offset:event:pasteboard:source:slideBack:] + 1767 5   AppKit                              0x00007fff27a610c1 -[NSWindow(NSDrag) dragImage:at:offset:event:pasteboard:source:slideBack:] + 134 6   AppKit                              0x00007fff27ec27fb -[NSTableView _doImageDragUsingRowsWithIndexes:event:pasteboard:source:slideBack:startRow:] + 665 7   AppKit                              0x00007fff27ec2cb2 -[NSTableView _checkOverrideAndDoImageDragUsingRowsWithIndexes:event:pasteboard:source:slideBack:startRow:] + 254 8   AppKit                              0x00007fff27ec3956 -[NSTableView _performClassicDragOfIndexes:hitRow:event:] + 444 9   AppKit                              0x00007fff27a88936 -[NSTableView _performDragFromMouseDown:] + 472 10  AppKit                              0x00007fff27a87fce -[NSTableView mouseDown:] + 5300 11  AppKit                              0x00007fff27935028 -[NSWindow(NSEventRouting) _handleMouseDownEvent:isDelayedEvent:] + 4956 12  AppKit                              0x00007fff278a413c -[NSWindow(NSEventRouting) _reallySendEvent:isDelayedEvent:] + 2594 13  AppKit                              0x00007fff278a34fe -[NSWindow(NSEventRouting) sendEvent:] + 347 14  AppKit                              0x00007fff278a18e8 -[NSApplication(NSEvent) sendEvent:] + 352 15  AppKit                              0x00007fff27b78cd6 -[NSApplication _handleEvent:] + 65 16  AppKit                              0x00007fff27709f83 -[NSApplication run] + 623 17  AppKit                              0x00007fff276dde14 NSApplicationMain + 816 18  SwiftUI                             0x00007fff363c8cd4 $s7SwiftUI6runAppys5NeverOSo21NSApplicationDelegate_pFTf4e_nAA07TestingdG0C_Tg5 + 100 19  SwiftUI                             0x00007fff36bf0162 $s7SwiftUI6runAppys5NeverOxAA0D0RzlF + 162 20  SwiftUI                             0x00007fff367b8e9d $s7SwiftUI3AppPAAE4mainyyFZ + 61 21  list                                0x0000000105397f71 $s4list0A3AppV5$mainyyFZ + 33 22  list                                0x0000000105397ff4 main + 20 23  libdyld.dylib                       0x00007fff6bf2d7d1 start + 1 24  ???                                 0x0000000000000003 0x0 + 3 ) Did I do something wrong or it's bug in SwiftUI? Is it possible to move more than 1 row at once? Thanks a lot!
2
0
1.7k
Jul ’20