Post

Replies

Boosts

Views

Activity

iPhone Duo: navigation bar item briefly moves to vertical bar during fullScreen dismissal despite .disabled
On the folded iPhone Duo display, a navigation bar item briefly moves into the vertical bar during dismissal of a full-screen modal, then jumps back to the top. Both navigation controllers consistently return .disabled from preferredVerticalBarBehavior, with childForPreferredVerticalBarBehavior returning nil. Environment Xcode 27.1 RC (27A9275), iOS 27.1 SDK, iPhone Duo simulator, folded outer display in portrait. Steps to reproduce Run the single-file UIKit example below in a scene-based app with a generated launch screen and no main storyboard. Tap the gear button on the Home screen to present Settings using .fullScreen. Tap the close button on Settings. Watch the Home screen's gear button during the dismissal animation. Expected The gear button stays in the top horizontal navigation bar throughout the transition, because the vertical bar preference is .disabled on both navigation controllers. Actual For part of the dismissal, the gear button appears below the status icons in the right-hand vertical bar region. It then jumps back to the top horizontal bar. The underlying tab bar also temporarily moves from the bottom to the right before returning. This reproduces with an otherwise empty view, standard UIKit containers, and the default bar appearance. No app code changes safeAreaInsets, bar frames, or animation timing. During the presentation/dismissal cycle, the Home view's logged right safe-area inset changes from 0 to 88 points and back to 0. In our app, content constrained to the safe area visibly narrows during the same transient change. In separate comparisons, returning .disabled from the root tab controller and content controllers, or requesting setNeedsUpdateOfVerticalBarConfiguration in appearance callbacks, did not eliminate the issue. Changing the modal to .overFullScreen avoided it in the tested simulator, but changes the underlying view controller lifecycle. The example below intentionally keeps .fullScreen to reproduce the problem. Is this expected behavior, or a known UIKit issue? Is there a supported way to keep .disabled effective throughout a fullScreen presentation/dismissal? Has this been addressed in a newer SDK/runtime? I have not tested iOS 27.2 or a physical Duo device. Minimal reproduction (one Swift file): import UIKit @main final class DemoAppDelegate: UIResponder, UIApplicationDelegate { func application(_ application: UIApplication, configurationForConnecting session: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration { let configuration = UISceneConfiguration(name: "Demo", sessionRole: session.role) configuration.delegateClass = DemoSceneDelegate.self return configuration } } final class DemoSceneDelegate: UIResponder, UIWindowSceneDelegate { var window: UIWindow? func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options: UIScene.ConnectionOptions) { guard let scene = scene as? UIWindowScene else { return } let home = DemoController() home.title = "首页" let navigation = DemoNavigationController(rootViewController: home) navigation.tabBarItem = UITabBarItem(title: "首页", image: UIImage(systemName: "house"), selectedImage: nil) let tabs = UITabBarController() if #available(iOS 18.0, *) { tabs.mode = .tabBar } tabs.viewControllers = [navigation] let window = UIWindow(windowScene: scene) window.rootViewController = tabs self.window = window window.makeKeyAndVisible() } } final class DemoNavigationController: UINavigationController { // 与音剪一致:导航容器固定横向栏,不转发给子页面。 @available(iOS 27.1, *) override var preferredVerticalBarBehavior: UIVerticalBarBehavior { .disabled } @available(iOS 27.1, *) override var childForPreferredVerticalBarBehavior: UIViewController? { nil } } final class DemoController: UIViewController { override func viewDidLoad() { super.viewDidLoad() view.backgroundColor = .systemBackground if title == "设置" { navigationItem.leftBarButtonItem = UIBarButtonItem(systemItem: .close, primaryAction: UIAction { [weak self] _ in self?.dismiss(animated: true) }) } else { navigationItem.rightBarButtonItem = UIBarButtonItem( image: UIImage(systemName: "gearshape"), primaryAction: UIAction { [weak self] _ in let settings = DemoController() settings.title = "设置" let navigation = DemoNavigationController(rootViewController: settings) navigation.modalPresentationStyle = .fullScreen self?.present(navigation, animated: true) }) } } override func viewDidLayoutSubviews() { super.viewDidLayoutSubviews() print("[DuoDemo] \(title ?? "") safe=\(view.safeAreaInsets) nav=\(navigationController?.navigationBar.frame ?? .zero) tab=\(tabBarController?.tabBar.frame ?? .zero)") } }
0
2
493
3w
ScaleTimeRange will cause noise in sound
I'm using AVFoundation to make a multi-track editor app, which can insert multiple track and clip, including scale some clip to change the speed of the clip, (also I'm not sure whether AVFoundation the best choice for me) but after making the scale with scaleTimeRange API, there is some short noise sound in play back. Also, sometimes it's fine when play AVMutableCompostion using AVPlayer with AVPlayerItem, but after exporting with AVAssetReader, will catch some short noise sounds in result file.... Not sure why. Here is the example project, which can build and run directly. https://github.com/luckysmg/daily_images/raw/refs/heads/main/TestDemo.zip
0
0
172
Jul ’25
Crash when set CAMetalLayer.presentsWithTransaction=true in background thread
When set metalLayer.presentsWithTransaction = true, and we call drawable.present() in bg thread (our rendering thread is not main thread), the app sometimes will crash with: *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Modifications to the layout engine must not be performed from a background thread after it has been accessed from the main thread.' Any solution?
1
0
1.6k
Jan ’23
How to get the height of padding in UINavigationBar
The top padding of UINavigationBar 's value is UIApplication.shared.statusBarFrame.height or UIApplication.shared.keyWindow?.safeAreaInsets.top ? Here is image See the blue box of the image https://github.com/luckysmg/daily_images/blob/main/20220928153515.jpg?raw=true Because two value is the same on devices older than iPhone14 Pro but is not the same on iPhone14 Pro and iPhone 14 Pro max. Which is the right value to get?
1
0
1.2k
Oct ’22
The view.layer.presentation() 's value is not accurate.
I add two view on screen. One is the blue view, other is orange view. And I use CADisplayLink to change orange view 's frame according to the blueView.layer.presentation.frame As expected, the orange view should cover the blue view completely, but we can see a gap and we can see a little part of blue view during keyboard animation. Here is demo code: class SecondViewController: UIViewController {       let textField = UITextField()       override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) {     self.textField.resignFirstResponder()   }       lazy var displayLink = CADisplayLink(target: self, selector: #selector(self.onDisplayLink))       @objc private func onDisplayLink () {     self.realBox.frame = CGRect(x: self.realBox.frame.origin.x, y: self.blueBox.layer.presentation()!.frame.origin.y, width: self.view.bounds.width, height: 100)   }       let blueBox = UIView()   let realBox = UIView()       override func viewDidLoad() {     super.viewDidLoad()     self.view.backgroundColor = .white           textField.frame = .init(x: 100, y: 100, width: 100, height: 100)     textField.backgroundColor = .red     self.view.addSubview(textField)           realBox.backgroundColor = .orange           blueBox.backgroundColor = .blue     blueBox.frame = .init(x: 0, y: self.view.bounds.height - 100, width: self.view.bounds.width, height: 100)     self.view.addSubview(blueBox)     self.view.addSubview(realBox)     realBox.frame = .init(x: 0, y:self.view.bounds.height - 100 , width: self.view.bounds.width, height: 100)           NotificationCenter.default.addObserver(forName: UIResponder.keyboardWillChangeFrameNotification, object: nil, queue: .main) { noti in       let userInfo = noti.userInfo!       let endFrame = userInfo[UIResponder.keyboardFrameEndUserInfoKey] as! CGRect       let isOpen = endFrame.intersects(self.view.bounds)       self.blueBox.frame = .init(x: 0, y: isOpen ? self.view.bounds.height - 100 - endFrame.height : self.view.bounds.height - 100, width: self.view.bounds.width, height: 100)     }           if #available(iOS 15.0, *) {       self.displayLink.preferredFrameRateRange = .init(minimum: 60, maximum: 120, preferred: 120)     } else {       self.displayLink.preferredFramesPerSecond = 120     }     self.displayLink.add(to: .main, forMode: .common)   } } So how to get an accurate value of the layer currently displayed on screen? Here is the video: https://github.com/luckysmg/daily_images/blob/main/RPReplay_Final1661168764.mov?raw=true
3
2
1.8k
Aug ’22
Is there a way to increase the frequency of touchesMoved method?
I have set CADisableMinimumFrameDurationOnPhone to YES And My device is iPhone13 Pro. The refresh rate is be 120HZ max. But the touchesMoved callback call with a frequency of 60HZ (16.66ms) in UIViewController It should be 120HZ (0.008s) on IPhone 13 pro Here is test code: import SwiftUI class HomeViewController: UIViewController,UIScrollViewDelegate {       override func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent?) {     let time = CFAbsoluteTimeGetCurrent()     print(time - oldTime) // 0.016s. But it should be 0.008s on iPhone13Pro     oldTime = time   }       var oldTime:CFAbsoluteTime = 0       override func viewDidLoad() {     super.viewDidLoad()     self.view.backgroundColor = .red   } } So How can I increase this frequency to 120HZ ?.
2
1
1.8k
Jul ’22
Does captureTextFromCamera API availability will change during App running ?
I use this method to judge this device whether supports the captureTextFromCamera API : let tf = UITextField() tf.canPerformAction(#selector(UIResponder.captureTextFromCamera(_:)),withSender: nil) This will return false on iPhoneX and return true on iPhone13 Pro So I want to know: On iPhone13Pro tf.canPerformAction(#selector(UIResponder.captureTextFromCamera(_:)),withSender: nil) Can this method return the false ? Or this value won't change for every device? Can I assume that this method will always return true on iPhone13 Pro and will always false on iPhoneX?
Topic: UI Frameworks SubTopic: UIKit Tags:
2
0
1.1k
Jun ’22
[AVAssetWriter addInput:] Format ID 'lpcm' is not compatible with file type com.apple.m4a-audio
This is the crash log from Firebase. Fatal Exception: NSInvalidArgumentException *** -[AVAssetWriter addInput:] Format ID 'lpcm' is not compatible with file type com.apple.m4a-audio But I can't reproduce the crash ... This is the demo code Does anyone know where the problem is ? let normalOutputSettings:[String:Any] = [     AVFormatIDKey : kAudioFormatLinearPCM,     AVSampleRateKey : 44100,     AVNumberOfChannelsKey : 2,     AVLinearPCMBitDepthKey : 16,     AVLinearPCMIsNonInterleaved : false,     AVLinearPCMIsFloatKey : false,     AVLinearPCMIsBigEndianKey : false   ] let writerInput = AVAssetWriterInput(mediaType: .audio, outputSettings: outputSettings) let outputURL = URL(fileURLWithPath: NSTemporaryDirectory() + UUID().uuidString + ".m4a") self.writer = try! AVAssetWriter(outputURL: outputURL, fileType: fileType) writer?.add(writerInput)
0
0
1.4k
Mar ’22
How to put the midi and recorded audio file into a single player?
The GarageBand app can import both midi and recorded audio file into a single player to play. Just like this: My App have the same feature but I don't know how to implement it. I have tried the AVAudioSequencer,but it only can load and play MIDI file. I have tried the AVPlayer and AVPlayerItem,but it seems that it can't load the MIDI file. So How to combine MIDI file and audio file into a single AVPlayerItem or anything else to play?
0
0
1.5k
Feb ’22
iPhone Duo: navigation bar item briefly moves to vertical bar during fullScreen dismissal despite .disabled
On the folded iPhone Duo display, a navigation bar item briefly moves into the vertical bar during dismissal of a full-screen modal, then jumps back to the top. Both navigation controllers consistently return .disabled from preferredVerticalBarBehavior, with childForPreferredVerticalBarBehavior returning nil. Environment Xcode 27.1 RC (27A9275), iOS 27.1 SDK, iPhone Duo simulator, folded outer display in portrait. Steps to reproduce Run the single-file UIKit example below in a scene-based app with a generated launch screen and no main storyboard. Tap the gear button on the Home screen to present Settings using .fullScreen. Tap the close button on Settings. Watch the Home screen's gear button during the dismissal animation. Expected The gear button stays in the top horizontal navigation bar throughout the transition, because the vertical bar preference is .disabled on both navigation controllers. Actual For part of the dismissal, the gear button appears below the status icons in the right-hand vertical bar region. It then jumps back to the top horizontal bar. The underlying tab bar also temporarily moves from the bottom to the right before returning. This reproduces with an otherwise empty view, standard UIKit containers, and the default bar appearance. No app code changes safeAreaInsets, bar frames, or animation timing. During the presentation/dismissal cycle, the Home view's logged right safe-area inset changes from 0 to 88 points and back to 0. In our app, content constrained to the safe area visibly narrows during the same transient change. In separate comparisons, returning .disabled from the root tab controller and content controllers, or requesting setNeedsUpdateOfVerticalBarConfiguration in appearance callbacks, did not eliminate the issue. Changing the modal to .overFullScreen avoided it in the tested simulator, but changes the underlying view controller lifecycle. The example below intentionally keeps .fullScreen to reproduce the problem. Is this expected behavior, or a known UIKit issue? Is there a supported way to keep .disabled effective throughout a fullScreen presentation/dismissal? Has this been addressed in a newer SDK/runtime? I have not tested iOS 27.2 or a physical Duo device. Minimal reproduction (one Swift file): import UIKit @main final class DemoAppDelegate: UIResponder, UIApplicationDelegate { func application(_ application: UIApplication, configurationForConnecting session: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration { let configuration = UISceneConfiguration(name: "Demo", sessionRole: session.role) configuration.delegateClass = DemoSceneDelegate.self return configuration } } final class DemoSceneDelegate: UIResponder, UIWindowSceneDelegate { var window: UIWindow? func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options: UIScene.ConnectionOptions) { guard let scene = scene as? UIWindowScene else { return } let home = DemoController() home.title = "首页" let navigation = DemoNavigationController(rootViewController: home) navigation.tabBarItem = UITabBarItem(title: "首页", image: UIImage(systemName: "house"), selectedImage: nil) let tabs = UITabBarController() if #available(iOS 18.0, *) { tabs.mode = .tabBar } tabs.viewControllers = [navigation] let window = UIWindow(windowScene: scene) window.rootViewController = tabs self.window = window window.makeKeyAndVisible() } } final class DemoNavigationController: UINavigationController { // 与音剪一致:导航容器固定横向栏,不转发给子页面。 @available(iOS 27.1, *) override var preferredVerticalBarBehavior: UIVerticalBarBehavior { .disabled } @available(iOS 27.1, *) override var childForPreferredVerticalBarBehavior: UIViewController? { nil } } final class DemoController: UIViewController { override func viewDidLoad() { super.viewDidLoad() view.backgroundColor = .systemBackground if title == "设置" { navigationItem.leftBarButtonItem = UIBarButtonItem(systemItem: .close, primaryAction: UIAction { [weak self] _ in self?.dismiss(animated: true) }) } else { navigationItem.rightBarButtonItem = UIBarButtonItem( image: UIImage(systemName: "gearshape"), primaryAction: UIAction { [weak self] _ in let settings = DemoController() settings.title = "设置" let navigation = DemoNavigationController(rootViewController: settings) navigation.modalPresentationStyle = .fullScreen self?.present(navigation, animated: true) }) } } override func viewDidLayoutSubviews() { super.viewDidLayoutSubviews() print("[DuoDemo] \(title ?? "") safe=\(view.safeAreaInsets) nav=\(navigationController?.navigationBar.frame ?? .zero) tab=\(tabBarController?.tabBar.frame ?? .zero)") } }
Replies
0
Boosts
2
Views
493
Activity
3w
ScaleTimeRange will cause noise in sound
I'm using AVFoundation to make a multi-track editor app, which can insert multiple track and clip, including scale some clip to change the speed of the clip, (also I'm not sure whether AVFoundation the best choice for me) but after making the scale with scaleTimeRange API, there is some short noise sound in play back. Also, sometimes it's fine when play AVMutableCompostion using AVPlayer with AVPlayerItem, but after exporting with AVAssetReader, will catch some short noise sounds in result file.... Not sure why. Here is the example project, which can build and run directly. https://github.com/luckysmg/daily_images/raw/refs/heads/main/TestDemo.zip
Replies
0
Boosts
0
Views
172
Activity
Jul ’25
Crash when set CAMetalLayer.presentsWithTransaction=true in background thread
When set metalLayer.presentsWithTransaction = true, and we call drawable.present() in bg thread (our rendering thread is not main thread), the app sometimes will crash with: *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Modifications to the layout engine must not be performed from a background thread after it has been accessed from the main thread.' Any solution?
Replies
1
Boosts
0
Views
1.6k
Activity
Jan ’23
How to get the height of padding in UINavigationBar
The top padding of UINavigationBar 's value is UIApplication.shared.statusBarFrame.height or UIApplication.shared.keyWindow?.safeAreaInsets.top ? Here is image See the blue box of the image https://github.com/luckysmg/daily_images/blob/main/20220928153515.jpg?raw=true Because two value is the same on devices older than iPhone14 Pro but is not the same on iPhone14 Pro and iPhone 14 Pro max. Which is the right value to get?
Replies
1
Boosts
0
Views
1.2k
Activity
Oct ’22
The view.layer.presentation() 's value is not accurate.
I add two view on screen. One is the blue view, other is orange view. And I use CADisplayLink to change orange view 's frame according to the blueView.layer.presentation.frame As expected, the orange view should cover the blue view completely, but we can see a gap and we can see a little part of blue view during keyboard animation. Here is demo code: class SecondViewController: UIViewController {       let textField = UITextField()       override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) {     self.textField.resignFirstResponder()   }       lazy var displayLink = CADisplayLink(target: self, selector: #selector(self.onDisplayLink))       @objc private func onDisplayLink () {     self.realBox.frame = CGRect(x: self.realBox.frame.origin.x, y: self.blueBox.layer.presentation()!.frame.origin.y, width: self.view.bounds.width, height: 100)   }       let blueBox = UIView()   let realBox = UIView()       override func viewDidLoad() {     super.viewDidLoad()     self.view.backgroundColor = .white           textField.frame = .init(x: 100, y: 100, width: 100, height: 100)     textField.backgroundColor = .red     self.view.addSubview(textField)           realBox.backgroundColor = .orange           blueBox.backgroundColor = .blue     blueBox.frame = .init(x: 0, y: self.view.bounds.height - 100, width: self.view.bounds.width, height: 100)     self.view.addSubview(blueBox)     self.view.addSubview(realBox)     realBox.frame = .init(x: 0, y:self.view.bounds.height - 100 , width: self.view.bounds.width, height: 100)           NotificationCenter.default.addObserver(forName: UIResponder.keyboardWillChangeFrameNotification, object: nil, queue: .main) { noti in       let userInfo = noti.userInfo!       let endFrame = userInfo[UIResponder.keyboardFrameEndUserInfoKey] as! CGRect       let isOpen = endFrame.intersects(self.view.bounds)       self.blueBox.frame = .init(x: 0, y: isOpen ? self.view.bounds.height - 100 - endFrame.height : self.view.bounds.height - 100, width: self.view.bounds.width, height: 100)     }           if #available(iOS 15.0, *) {       self.displayLink.preferredFrameRateRange = .init(minimum: 60, maximum: 120, preferred: 120)     } else {       self.displayLink.preferredFramesPerSecond = 120     }     self.displayLink.add(to: .main, forMode: .common)   } } So how to get an accurate value of the layer currently displayed on screen? Here is the video: https://github.com/luckysmg/daily_images/blob/main/RPReplay_Final1661168764.mov?raw=true
Replies
3
Boosts
2
Views
1.8k
Activity
Aug ’22
Is there a way to increase the frequency of touchesMoved method?
I have set CADisableMinimumFrameDurationOnPhone to YES And My device is iPhone13 Pro. The refresh rate is be 120HZ max. But the touchesMoved callback call with a frequency of 60HZ (16.66ms) in UIViewController It should be 120HZ (0.008s) on IPhone 13 pro Here is test code: import SwiftUI class HomeViewController: UIViewController,UIScrollViewDelegate {       override func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent?) {     let time = CFAbsoluteTimeGetCurrent()     print(time - oldTime) // 0.016s. But it should be 0.008s on iPhone13Pro     oldTime = time   }       var oldTime:CFAbsoluteTime = 0       override func viewDidLoad() {     super.viewDidLoad()     self.view.backgroundColor = .red   } } So How can I increase this frequency to 120HZ ?.
Replies
2
Boosts
1
Views
1.8k
Activity
Jul ’22
Does captureTextFromCamera API availability will change during App running ?
I use this method to judge this device whether supports the captureTextFromCamera API : let tf = UITextField() tf.canPerformAction(#selector(UIResponder.captureTextFromCamera(_:)),withSender: nil) This will return false on iPhoneX and return true on iPhone13 Pro So I want to know: On iPhone13Pro tf.canPerformAction(#selector(UIResponder.captureTextFromCamera(_:)),withSender: nil) Can this method return the false ? Or this value won't change for every device? Can I assume that this method will always return true on iPhone13 Pro and will always false on iPhoneX?
Topic: UI Frameworks SubTopic: UIKit Tags:
Replies
2
Boosts
0
Views
1.1k
Activity
Jun ’22
[AVAssetWriter addInput:] Format ID 'lpcm' is not compatible with file type com.apple.m4a-audio
This is the crash log from Firebase. Fatal Exception: NSInvalidArgumentException *** -[AVAssetWriter addInput:] Format ID 'lpcm' is not compatible with file type com.apple.m4a-audio But I can't reproduce the crash ... This is the demo code Does anyone know where the problem is ? let normalOutputSettings:[String:Any] = [     AVFormatIDKey : kAudioFormatLinearPCM,     AVSampleRateKey : 44100,     AVNumberOfChannelsKey : 2,     AVLinearPCMBitDepthKey : 16,     AVLinearPCMIsNonInterleaved : false,     AVLinearPCMIsFloatKey : false,     AVLinearPCMIsBigEndianKey : false   ] let writerInput = AVAssetWriterInput(mediaType: .audio, outputSettings: outputSettings) let outputURL = URL(fileURLWithPath: NSTemporaryDirectory() + UUID().uuidString + ".m4a") self.writer = try! AVAssetWriter(outputURL: outputURL, fileType: fileType) writer?.add(writerInput)
Replies
0
Boosts
0
Views
1.4k
Activity
Mar ’22
How to put the midi and recorded audio file into a single player?
The GarageBand app can import both midi and recorded audio file into a single player to play. Just like this: My App have the same feature but I don't know how to implement it. I have tried the AVAudioSequencer,but it only can load and play MIDI file. I have tried the AVPlayer and AVPlayerItem,but it seems that it can't load the MIDI file. So How to combine MIDI file and audio file into a single AVPlayerItem or anything else to play?
Replies
0
Boosts
0
Views
1.5k
Activity
Feb ’22