Post

Replies

Boosts

Views

Activity

How to make LazyVGrid not to be lazy?
Inside my ScrollView, there is LazyVGrid view on the top of other View. After scrolling to bottom, when I scroll to top slowly, I notice that LazyVGrid view disappears for a while. My code struct ContentView: View {   var body: some View {     NavigationView {       GeometryReader { proxy in         ScrollView(.vertical) {           LazyVStack {             LazyVGrid(columns: proxy.size.width > proxy.size.height ? Array(repeating: GridItem(.flexible(), spacing: 15, alignment: .top), count: 2) : Array(repeating: GridItem(.flexible(), alignment: .top), count: 1)) {               ForEach(0..<6, id: \.self) { index in                 Color(red: Double.random(in: 0...1), green: Double.random(in: 0...1), blue: Double.random(in: 0...1))                   .frame(height: 300)                   .id(index)               }             }             Color(red: Double.random(in: 0...1), green: Double.random(in: 0...1), blue: Double.random(in: 0...1))               .frame(height: 400)           }         }       }     }   } } My question is how to prevent LazyVGrid not to be destroyed after disappearing. Thanks.
2
0
1.7k
Jul ’20
AVPlayer does not work in Xcode 12 beta
I just created code for audio player. It works in Xcode 11.5 perfectly. Unfortunately, when I use Xcode 12 beta, it does not work like in Xcode 11.5. I got too many warnings. Here is my code. struct ContentView: View {   @ObservedObject var player: Player = .shareInstance   var body: some View {     Button(action: {       self.player.play()     }) {       Text("Play")     }   } } class Player: ObservableObject {   static var shareInstance = Player()   var audioPlayer: AVPlayer!   func play() {     guard let url = URL(string: "https://www.soundhelix.com/examples/mp3/SoundHelix-Song-1.mp3") else {       print("Invalid url")       return     }     let playerItem = AVPlayerItem(url: url)     audioPlayer = AVPlayer(playerItem: playerItem)     audioPlayer.play()   } } Warnings 2020-07-03 09:45:28.914989+0630 AudioPlayer[96225:4422734] [] nwprotocolgetquicimageblockinvoke dlopen libquic failed 2020-07-03 09:45:30.336438+0630 AudioPlayer[96225:4422744] [plugin] AddInstanceForFactory: No factory registered for id &lt;CFUUID 0x600001f3a720&gt; F8BB1C28-BAE8-11D6-9C31-00039315CD46 2020-07-03 09:45:30.482683+0630 AudioPlayer[96225:4422869] HALBIOBufferManagerClient::GetIOBuffer: the stream index is out of range 2020-07-03 09:45:30.483346+0630 AudioPlayer[96225:4422869] HALBIOBufferManagerClient::GetIOBuffer: the stream index is out of range 2020-07-03 09:45:30.495630+0630 AudioPlayer[96225:4422869] [aqme] 255: AQDefaultDevice (1): output stream 0: null buffer 2020-07-03 09:45:30.496099+0630 AudioPlayer[96225:4422869] [aqme] 1778: EXCEPTION thrown (-50): error != 0 2020-07-03 09:45:45.485455+0630 AudioPlayer[96225:4422744] [aqme] 182: timed out after 15.000s (0 1); suspension count=0 (IOSuspensions: ) 2020-07-03 09:45:45.486826+0630 AudioPlayer[96225:4422744] 244: CAUISoundClientBase::StartPlaying: AddRunningClient failed (status = -66681). 2020-07-03 09:45:45.615673+0630 AudioPlayer[96225:4422989] HALBIOBufferManagerClient::GetIOBuffer: the stream index is out of range 2020-07-03 09:45:45.616021+0630 AudioPlayer[96225:4422989] HALBIOBufferManager_Client::GetIOBuffer: the stream index is out of range 2020-07-03 09:45:45.628154+0630 AudioPlayer[96225:4422989] [aqme] 255: AQDefaultDevice (1): output stream 0: null buffer 2020-07-03 09:45:45.628978+0630 AudioPlayer[96225:4422989] [aqme] 1778: EXCEPTION thrown (-50): error != 0 2020-07-03 09:46:00.617994+0630 AudioPlayer[96225:4422986] [aqme] 182: timed out after 15.000s (1 2); suspension count=0 (IOSuspensions: ) Thanks
2
0
3.1k
Jul ’20