Post

Replies

Boosts

Views

Activity

Close PIP video when the video ends?
I'm using AVPlayerViewController to play a local video inline. My desired behavior is that videos playing in a PIP window will close automatically when the video ends. Is there a way to do this with AVPlayerViewController? import UIKit import AVKit class ViewController: UIViewController { 		var playerViewController = AVPlayerViewController() 		var videoPath = "video.mov" 		override func viewDidLoad() { 				super.viewDidLoad() 				 				do { 						try AVAudioSession.sharedInstance().setCategory(AVAudioSession.Category.playback) 				} catch { } 						 				let player = AVPlayer(url: URL(fileURLWithPath: videoPath)) 				playerViewController.player = player 				NotificationCenter.default.addObserver( 						self, 						selector: #selector(playerDidFinishPlaying), 						name: .AVPlayerItemDidPlayToEndTime, 						object: player.currentItem 				) 						 				playerViewController.showsPlaybackControls = true 				playerViewController.entersFullScreenWhenPlaybackBegins = true 				self.addChild(playerViewController) 				self.view.addSubview(playerViewController.view) 		} 		 		@objc func playerDidFinishPlaying(note: NSNotification) { 				 // ??? 		} }
0
1
896
Jul ’20
Animate through multiple pages with UIPageViewController?
I am using UIPageViewController to create a horizontal list of pages. I want to have a button that will cause a transition to a specific page. I can do this by using setViewControllers. setViewControllers( 		[viewController], 		direction: .forward, 		animated: true, 		completion: nil ) However this will not animate over multiple pages. The animation makes it appear that the new page is directly next to the old page, even they are not next to each other in my data. An example of the animation I'm thinking of is hitting the home button on the iOS home screen. One thing I've tried is starting another animation in the completion handler, but for some reason there is no animation on the second transition. setViewControllers( 		[viewController], 		direction: .forward, 		animated: true, 		completion: { _ in 				/*Second Transition*/ 				self.setViewControllers( 						[nextViewController], 						direction: .forward, 						animated: true, 						completion: nil 				) 		} )
1
0
1.5k
Jul ’20
Popover arrow is not pointing to the correct location after changing app size in iPadOS split view
I have a popover that is attached to a UIBarButtonItem and I am experiencing an issue with the location of the arrow in the popover's navigation bar. My desired behavior is to have the arrow pointing at the bar button item that triggered the popover to display. To to this, I have the following IBAction attached to the bar button from storyboard. @IBAction func openPopover(_ sender: Any) { 		let navigationController = UINavigationController(rootViewController: myViewController) 		navigationController.modalPresentationStyle = .popover 		let popover = navigationController.popoverPresentationController 		myViewController.preferredContentSize = CGSize(width: 500, height: 820) 		popover?.delegate = self 		popover?.sourceView = self.view 		popover?.permittedArrowDirections = .up 		popover?.barButtonItem = myBarButtonItem 		present(navigationController, animated: true) } This creates the desired behavior, where the arrow of the popover points at myBarButtonItem, even after rotation and in split view. My issue is when I create and present the popover when the app is in the 1/3 screen width on iPadOS. The popover will be presented as a modal, and when I change the app to a larger size that is not a compact horizontal size class, the arrow will be way too far right of the bar button item. The issue only happens when the app size is changed from 1/3 screen size width to a non compact horizontal size class. When the app changes from 1/2 screen size on the 11 inch iPad Pro to full screen, the issue does not occur even though 1/2 screen width on 11 inch iPad Pro is also a compact horizontal size class. The issue occurs on the simulator and on device.
0
0
1k
Aug ’20