Post not yet marked as solved
Hi,
I think I never thought about this but... let's say I have my iOS app (swift) and I have a ViewController with a WKWebView. If I open a link of a page with a pdf, where are the pdf and that page's files stored? Is there a way to clean the directory in which those files get stored? Is it something I shouldn't worry about?
Thanks in advance
Hi,
I have a ViewController that presents another ViewController as a modal over full screen when a button is touched.
let vc = UIStoryboard(name: "***", bundle: nil).instantiateViewController(withIdentifier: "OverFullScreenModalViewController") as! OverFullScreenModalViewController
vc.modalPresentationStyle = .overFullScreen
vc.modalTransitionStyle = .crossDissolve
self.present(vc, animated: true, completion: nil)
Then, on my modal ViewController I have a button that, when touched, I want to present a confirmation alert
@IBAction func handleDelete(_ sender: Any) {
let negativeHandler:((Any) -> ()) = {(_) in
//do nothing
}
let handler:((Any) -> ()) = {(_) in
// Delete
}
DispatchQueue.main.async {
let alert = UIAlertController(title: "Please confirm", message: "Are you sure?", preferredStyle: .alert)
let positiveAction = UIAlertAction(title: "yes", style: .default, handler: handler)
alert.addAction(UIAlertAction(title: "no", style: .cancel, handler: negativeHandler))
alert.addAction(positiveAction)
alert.preferredAction = positiveAction
self.present(alert, animated: true)
}
}
But what happens is that the modal is dismissed and I get this error on the console:
[Presentation] Attempt to present <UIAlertController: 0x7ff78d37cc00> on <OverFullScreenModalViewController: 0x7ff792814200> (from <OverFullScreenModalViewController: 0x7ff792814200>) whose view is not in the window hierarchy.
I've tried with and without DispatchQueue.main.async, nothing is trying to be presented on viewDidLoad, viewWillAppear or viewDidAppear
Any ideas?
Post not yet marked as solved
Hi,
I have an app that uses AVPlayer to stream and play videos (HLS) but I'm struggling to find a way to do the same with fmp4.
This is what I use to play my HLS stream. I tried just to replace the url with the fmp4 one but it does not work.
private func connect() {
let stringUrl = "https://wolverine.raywenderlich.com/content/ios/tutorials/video_streaming/foxVillage.m3u8"
let url = URL(string: stringUrl)!
let asset = AVURLAsset(url: url)
let item = AVPlayerItem(asset: asset)
if #available(iOS 10.0, *) {
item.preferredForwardBufferDuration = Double(50000) / 1000
}
if #available(iOS 13.0, *) {
item.automaticallyPreservesTimeOffsetFromLive = true
}
self.player = AVPlayer(playerItem: item)
let playerLayer = AVPlayerLayer(player: self.player)
playerLayer.frame = self.playerView.bounds
playerLayer.videoGravity = .resizeAspect
self.playerView.layer.addSublayer(playerLayer)
self.videoLayer = playerLayer
self.videoLayer?.frame = self.playerView.bounds
player?.play()
}
I haven't got any luck looking for a possible solution and I'm out of ideas. I'll be really grateful if anyone of you could point me to a good direction.