Post

Replies

Boosts

Views

Activity

iOS 14 VideoPlayer has NavigationBar issue?
Hello I'm facing a problem on new Video Player view from iOS 14 Now, I'm trying to use Video Player introduced on iOS 14+ in a View routed from Navigation Link. I have set up navigationBarBackButtonHidden -> true navigationBarHidden -> true navigationBarTitle("", displayMode: .inline) statusBar -> hidden: true edgesIgnoringSafeArea -> all However, when VideoPlayer's mp4 video will start to be played, NavigationBar will be shown. To narrow down the issue, I tried to put Colored Rectangle on the area for VideoPlayer instead. Then, NavigationBar won't be shown. I suspect that this issue is VideoPlayer View's bug, but I hope this is not a bug. Does anyone know correct way or how to avoid Navigation Bay display when using VideoPlayer ? This issue happens on both simulator and iPad device. Best regards,
3
0
1.3k
Nov ’20
Continuous loop playback on AVAudioPlayer make memory leak?
Hello folks, Now, I'm trying to make continuous loop playback function with AVAudioPlayer. After I implemented sample code as below, and I checked memory usage. As a result of 1 hour loop, memory usage kept increasing for a hour from start to end. My app is expected to run for over 10 hours or over. so, I think that I need to solve memory leak problem. Does someone know how to avoid kind of memory leak? My implementation way(code design standard or @escaping async function, etc...) is not good or not typical way for continuous audio loop playback? or The way to use AVAudioPlayer is not correct? If someone knows that, that will save my life. Best regards,
2
0
1.6k
Aug ’21
How to read a local value correctly both in Combine's sink scope and in the scope that Combine's sink was defined?
Now I want to notify value change from delegate event to another func() and returns the new value with callback(). To do that, I tried to write test program as below. However, problem happened. import SwiftUI struct ContentView: View {       let cst = CombineSinkTest()       var body: some View {     Button(action: {       cst.sinkTest(stCount: 0){ sinkResult in         print("finish")       }     }){       Text("Push")     }   } } import Foundation import Combine final public class CombineSinkTest: NSObject{       var stringPublisher = PassthroughSubject<String?, Never>()   var cancellables = [AnyCancellable]()         private var globalNum = 0   var sinkDefinedFlag = false       func sinkTest(stCount: Int, completion: @escaping (Bool) -> Void){     var localCount = stCount           childSink(count: localCount){ childResult in       localCount += 1       DispatchQueue.main.asyncAfter(deadline: .now() + 1.5) {         self.sinkTest(stCount: localCount){ stResult in           completion(true)         }       }     }   }       func childSink(count: Int, completion: @escaping (Bool) -> Void ){     globalNum += 1     let localNum = globalNum           print("globalNum: \(localNum)")           if(sinkDefinedFlag == false) {       self.stringPublisher         .sink(receiveCompletion: { print ("completion: \($0)") },          receiveValue: {           print ("received: \($0)")           print("local value: \(localNum)")           completion(true)          })         .store(in: &cancellables)       sinkDefinedFlag = true     } (a)    generateNotification()         }     (a)  private func generateNotification() {     stringPublisher.send("")   } } (a) is test-purpose. (a)'s func is planned to be delegate event. I want to let receiveValue: in .sink to use localCount number. However, localCount won't increase at all... globalNum: 1 localNum in caller of .sink: 1 received: Optional("") localNum in .sink: 1  globalNum: 2 localNum in caller of .sink: 2 received: Optional("") localNum in .sink: 1  globalNum: 3 localNum in caller of .sink: 3 received: Optional("") localNum in .sink: 1  globalNumber is increasing. And, localNum in func defining .sink. However, localCount in .sink closure won't increase. How should I change the code for passing updated localNum into .sink closure? Sorry for not good English... Best regards,
2
0
689
Jul ’21
How to change thread or reference of NotificationCenter's handler when observing value change
Hello Everyone, I'm now facing a issue that number counting won't work correctly when I use Notification Center(I tried to narrow down the problem area as below's code and Notification Center seems to be problem's root) I suspect that the problem cause from Thread location or reference on NotificationCenter's handler when observing value change. So, I think that If I can change thread location or reference following thread location or reference of the method that defined addObserver. Am I correct? and does someone know how to make the code correct? Code is below ContentView.swift struct ContentView: View {   @ObservedObject var cht = CompletionHandlerTest()         var body: some View {     Button(action:{       cht.startCount(list: ["A", "B","C", "D", "E"]){ isCompleteCount in         print("countEnd")       }     }){       Text("start")     }     .padding()   } } struct ContentView_Previews: PreviewProvider {   static var previews: some View {     ContentView()   } } CompletionHandlerTest.swift import SwiftUI public class CompletionHandlerTest: ObservableObject {     @Published var counter: Int = 0       private let nbc = NotificationBasedCompletion.shared       func startCount(list: [String], completion: @escaping(Bool) -> Void) {     print("count start")           countTest(items: list, count: 0){ isSuccessful in       completion(true)       print("countTest is finished")     }   }     private func countTest(items: [String], count: Int, completion: @escaping(Bool) -> Void){           if(count >= items.count){       completion(true)     }     else {       print("count in countTest -> \(count)")       nbc.notifyForTest(label: items[count]){ isPrintSuccessful in                   print("countTest will call-> count: \(count) + 1")         DispatchQueue.main.asyncAfter(deadline: .now() + 0.7) {           self.countTest(items: items, count: count+1) { isCountSuccessful in             completion(true)           }         }       }     }   }     }   NotificationBasedCompletion.swift final public class NotificationBasedCompletion: NSObject{       public static let shared = NotificationBasedCompletion()   private var observer: NSObjectProtocol?         func notifyForTest(label: String, completion: @escaping (Bool) -> Void ){               if(observer == nil){       observer = NotificationCenter.default.addObserver(forName: NSNotification.Name("notifyStatus"), object: nil, queue: .main){ (_) in                   let notifyStatus = UserDefaults.standard.value(forKey: "notifyStatus") as? Bool ?? false                   if notifyStatus {           completion(true)         }                 }     }           //if below code is used, count won't proceed     generateNotification()           // if below code is used, count will count correctly     //completion(true)   }       private func generateNotification() {     print("let's notify!")     UserDefaults.standard.set(true, forKey: "notifyStatus")     NotificationCenter.default.post(name:NSNotification.Name("notifyStatus"), object: nil)   }     } When executing above code, then print as below count start count in countTest -> 0 let's notify! countTest will call-> count: 0 + 1 count in countTest -> 1 let's notify! countTest will call-> count: 0 + 1 count in countTest -> 1 let's notify! countTest will call-> count: 0 + 1 count in countTest -> 1 I hope that someone knows about the issue. Best regards,
1
0
882
Jul ’21
How to load mp3 on Library Folder and play it.
Hello Everyone, I'm Hiro Now I'm trying to load mp3 on Library Folder and play it. (Originally, the mp3 file was on bundle.main.path and was stored on Library Folder. And that seems being success) let storedURL = directoryUrl.appendingPathComponent(fileName) // same url when a mp3 file was stored on Library Folder do {           let audioPlayer = try AVAudioPlayer(contentsOf: storedURL, fileTypeHint: AVFileType.mp3.rawValue)           audioPlayer.play()         } catch let error {           print(error.localizedDescription)         } When I did above code, below error would happen. 2021-07-06 15:41:24.968272+0900 FileSaveSample[1438:69214] [aqsrv] AQServer.cpp:68:APIResult: Exception caught in AudioQueueInternalNotifyRunning - error -66671 And, the sound won't play on simulator and actual device. Am I wrong on something basic? I use XCode 12.5.1 and iOS 14. Best regards,
5
0
4.7k
Jul ’21
How to draw animated gif?
Hi everyone Thanks to this forum, even beginner, I can progress my app project. Now, I want to let my app to display animated gif. I tried to put animated gif onto xcassets, and use standard "Image" view. However, animated gif image has not been displayed. I suppose iOS SDK does not support animated gif officially. However, is there some other ways than official one? Best regards,
2
0
7.6k
Nov ’20
PNG has not been display on Image class for Swift UI
Hello I've been trying to draw transparent PNG file. Following typical way, I wrote down as below VStack { Image("*file name*") } Then, PNG image's stroke has been drawn.(so, I can recognize the shape of the image and size). However, kind of body area of PNG image has not been drawn.(Semi-transparent gray has been drawn for this area)   I want to solve the situation. Problem is file format? or Program? Have any of you ever had issues like that? Or maybe you just know what’s going on and how to fix it?
4
0
3.3k
Oct ’20