Post

Replies

Boosts

Views

Activity

iOS 16 Autorotation strange issue
I am seeing a strange issue with autorotation on iOS 16 that is not seen in other iOS versions. And worse, the issue is NOT seen if I connect device to XCode and debug. It is ONLY seen when I directly launch the app on device once it is installed, and that's the reason I am unable to identify any fix. So here is the summary of the issue. I disable autorotation in the app till the camera session starts running. Once camera session starts running, I fire a notification to force autorotation of device to current orientation. var disableAutoRotation: Bool { if !cameraSessionRunning { return true } return false } override var supportedInterfaceOrientations: UIInterfaceOrientationMask { var orientations:UIInterfaceOrientationMask = .landscapeRight if !self.disableAutoRotation { orientations = .all } return orientations } func cameraSessionStartedRunning(_ session:AVCaptureSession?) { DispatchQueue.main.asyncAfter(deadline: .now(), execute: { /* * HELP::: This code does something only when debug directly from XCode, * not when directly launching the app on device!!!! */ cameraSessionRunning = true if #available(iOS 16.0, *) { UIView.performWithoutAnimation { self.setNeedsUpdateOfSupportedInterfaceOrientations() } } else { // Fallback on earlier versions UIViewController.attemptRotationToDeviceOrientation() } self.layoutInterfaceForOrientation(self.windowOrientation) }) }
Topic: UI Frameworks SubTopic: UIKit Tags:
4
2
2.7k
Sep ’22
iOS 16 mismatch between windowScene & UIViewController interfaceOrientation
This is another strange issue on iOS 16, and one among the many woes that cause autoRotation problems on the platform. At the app startup time, there is a mismatch between -[UIViewController interfaceOrientation] (now deprecated), -[UIViewController supportedInterfaceOrientations] (which returns .landscapeRight), and -[windowScene interfaceOrientation].  public var windowOrientation: UIInterfaceOrientation {         return view.window?.windowScene?.interfaceOrientation ?? .unknown     }  override func viewDidLayoutSubviews() {         super.viewDidLayoutSubviews()      layoutInterfaceForOrientation(windowOrientation)     }  override var supportedInterfaceOrientations: UIInterfaceOrientationMask {         return .landscapeRight Putting a breakpoint in viewDidLayoutSubviews reveals that windowOrientation is portrait while interfaceOrientation is .landscapeRight. Is there anyway this can be fixed or any workaround possible?
Topic: UI Frameworks SubTopic: UIKit Tags:
0
0
607
Sep ’22
XCode 14 SwiftUI dyld symbol not found
I get this error when I run my code on an iOS 14 device using XCode 14. dyld: Symbol not found: _$s7SwiftUI15GraphicsContextV4fill_4with5styleyAA4PathV_AC7ShadingVAA9FillStyleVtF Referenced from: ****** Expected in: /System/Library/Frameworks/SwiftUI.framework/SwiftUI I do not get any errors when I run the same code on an iOS 15 or iOS 16 device. How do I resolve this issue?
1
0
1.7k
Sep ’22
Workaround for iOS 16 Autorotation bugs
iOS 16 has serious bugs in UIKit without any known workarounds, so much that I had to remove my app from sale. Obviously I am affected and am desperate to know if anyone has found any workaround or if UIKit Engineers can tell me any workarounds. To summarise, the issue is calling setNeedsUpdateOfSupportedInterfaceOrientations shortly (within 0.5 seconds) after app launch doesn't trigger autorotation. It does trigger autorotation when the device is launched from the debugger but not when the app is launched directly. Maybe the debugger incurs some delay that is perhaps sufficient to trigger autorotation? I have filed FB11516363 but need a workaround desperately so as to get my app back on AppStore.
0
0
1.8k
Sep ’22
AVAudioEngine exception - required condition is false format.sampleRate == hwFormat.sampleRate
I see in Crashlytics few users are getting this exception when connecting the inputNode to mainMixerNode in AVAudioEngine: Fatal Exception: com.apple.coreaudio.avfaudio required condition is false: format.sampleRate == hwFormat.sampleRate Here is my code: self.engine = AVAudioEngine() let format = engine.inputNode.inputFormat(forBus: 0) //main mixer node is connected to output node by default engine.connect(self.engine.inputNode, to: self.engine.mainMixerNode, format: format) Just want to understand how can this error occur and what is the right fix?
2
1
3.4k
Aug ’22
AVFoundation crash in getting power levels from Audio channel
@AVFoundation engineers, my users am seeing the following crash which I can not reproduce at my end. *** -[__NSArrayI objectAtIndexedSubscript:]: index 2 beyond bounds [0 .. 1] Fatal Exception: NSRangeException 0 CoreFoundation 0x99288 __exceptionPreprocess 1 libobjc.A.dylib 0x16744 objc_exception_throw 2 CoreFoundation 0x1a431c -[__NSCFString characterAtIndex:].cold.1 3 CoreFoundation 0x4c96c CFDateFormatterCreateStringWithAbsoluteTime 4 AVFCapture 0x6cad4 -[AVCaptureConnection getAvgAudioLevelForChannel:] All I am doing is this:  func updateMeters() {         var channelCount = 0         var decibels:[Float] = []         let audioConnection = self.audioConnection         if let audioConnection = audioConnection {             for audioChannel in audioConnection.audioChannels {                 decibels.append(audioChannel.averagePowerLevel)                 channelCount = channelCount + 1             }         }          What am I doing wrong?
2
0
711
Aug ’22
UITextView contentInset default animation
I have this code to adjust UITextView when keyboard is about to be displayed. @objc func keyboardWillShow(notification: NSNotification) { if let rectValue = notification.userInfo?[UIResponder.keyboardFrameEndUserInfoKey] as? NSValue { let keyboardSize = rectValue.cgRectValue.size let contentInsets: UIEdgeInsets = UIEdgeInsets(top: 0, left: 0, bottom: keyboardSize.height - view.safeAreaInsets.bottom, right: 0) textView.contentInset = contentInsets textView.scrollIndicatorInsets = contentInsets } } I see setting contentInset automatically creates a scrolling animation (after the keyboard appears fully) that makes the text at the cursor visible. The animation happens automatically and there is no way to disable it. I want to scroll to a given location in the textView sometimes when the keyboard is presented (preferably, animating it along with keyboard appearance). The implicit contentInset animation makes it impossible however. First the keyboard animates, then contentInset animates, and now only can I animate to my chosen location in textView. This is awkward. I am wondering what is the right way to achieve it?
Topic: UI Frameworks SubTopic: UIKit Tags:
0
0
630
Jul ’22
UICollectionViewFlowLayout disable dynamic sizing
I have a UICollectionViewFlowLayout assigned to UICollectionView. It's delegate method returns fixed CGSize in sizeForItemAtIndexPath. The problem is if UICollectionViewCell contains UIImageView or any other dynamically sized view with autolayout constraints that match leading, trailing, top, bottom to contentView, the cell resizes depending on the size of image in the imageView. Is it possible to get fixed size cells with UICollectionViewFlowLayout? I tried setting intrinsicContentSize for UIImageView in storyboard but it doesn't work.
Topic: UI Frameworks SubTopic: UIKit Tags:
0
0
425
Jun ’22
Adding UILabel to UIContentViewCell disturbs it's size
I have a UICollectionViewCell defined in storyboard which has a UILabel added to it's contentView. Collection view uses a flow layout and I return a fixed size of cell in flowlayout delegate as follows: let sizeOfItem = CGFloat(210.0) func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { return CGSize(width: sizeOfItem, height: sizeOfItem) } I added the following constraint for UILabel in storyboard and the cell automatically starts resizing itself to match the text size in UILabel. This is not what I want. I want the cell to be fixed size and label to autoshrink instead. I even tried setting contentHuggingPriority of label to lowest value (i.e. 1). This stops the cell from auto-shrinking if the text in label is small. But the cell grows when the text is bigger. I don't want this to happen either. I want the cell to remain fixed size and label to adapt it's font and be constrained within the cell.
0
0
597
Jun ’22
Implementing Tone Curves using Metal/Core Image
I am trying to develop tone curves filter using Metal or Core Image as I find CIToneCurve filter is having limitations (number of points are atmost 5, spline curve it is using is not documented, and sometimes output is a black image even with 4 points). Moreover it's not straightforward to have separate R,G,B curves independently. I decided to explore other libraries that implement tone curve and the only one that I know is GPUImage (few others borrow code from the same library). But the source code is too cryptic to understand and I have [doubts] about the manner in which it is generating look up texture (https://stackoverflow.com/questions/70516363/gpuimage-tone-curve-rgbcomposite-filter). Can someone explain how to correctly implement R,G,B, and RGB composite curves filter like in Mac Photos App?
1
1
2k
May ’22
UITextView rich text editing
I need to implement a text editor using UITextView that supports: Bold/Italic/Underline Color,Font,font size changes Paragraph alignment List format (bullets, numbers, etc.) Custom selection of text anywhere in the text view and change the properties So far I have managed to do it without NSTextStorage but it seems I am hitting limits. For instance, to change font, I use UIFontPickerViewController and change the font as follows: func fontPickerViewControllerDidPickFont(_ viewController: UIFontPickerViewController) { if let selectedFontDesc = viewController.selectedFontDescriptor { let font = UIFont(descriptor: selectedFontDesc, size: selectedFontDesc.pointSize) self.selectedFont = font self.textView.typingAttributes = [NSAttributedString.Key.foregroundColor: self.selectedColor ?? UIColor.white, NSAttributedString.Key.font: self.selectedFont ?? UIFont.preferredFont(forTextStyle: .body, compatibleWith: nil)] if let range = self.textView.selectedTextRange, let selectedFont = selectedFont { let attributedText = NSMutableAttributedString(attributedString: self.textView.attributedText) let location = textView.offset(from: textView.beginningOfDocument, to: range.start) let length = textView.offset(from: range.start, to: range.end) let nsRange = NSRange(location: location, length: length) attributedText.setAttributes([NSAttributedString.Key.font : selectedFont], range: nsRange) self.textView.attributedText = attributedText } } } This works but the problem is it resets the color of the selected text and other properties. I need to understand a way in which the existing attributed of the text under selection are not disturbed. I suspect the way to do is with using NSTextStorage but I can't find anything good on internet that explains the right use of NSTextStorage to achieve this.
1
0
1.7k
May ’22
AVPlayer display on external screen transform
I have an AVPlayerLayer and AVPlayer setup for playback on external screen as follows: var player = AVPlayer() playerView.player = player       player.usesExternalPlaybackWhileExternalScreenIsActive = true  player.allowsExternalPlayback = true playerView is just a UIView that has AVPlayerLayer as it's main layer. This code works and automatically starts displaying and playing video on external screen. The thing is I want an option to invert the AVPlayerLayer on the external screen. I tried setting transform on playerView but that is ignored on the external screen. How do I gain more control on the external screen window? I also tried to manually add playerView to external screen window and set player.usesExternalPlaybackWhileExternalScreenIsActive = true I can also display AVPlayerLayer manually this way. But again, setting a transform on this screen has no effect on external display. So it may also be a UIKit issue.
1
0
1.3k
May ’22
iOS 16 Autorotation strange issue
I am seeing a strange issue with autorotation on iOS 16 that is not seen in other iOS versions. And worse, the issue is NOT seen if I connect device to XCode and debug. It is ONLY seen when I directly launch the app on device once it is installed, and that's the reason I am unable to identify any fix. So here is the summary of the issue. I disable autorotation in the app till the camera session starts running. Once camera session starts running, I fire a notification to force autorotation of device to current orientation. var disableAutoRotation: Bool { if !cameraSessionRunning { return true } return false } override var supportedInterfaceOrientations: UIInterfaceOrientationMask { var orientations:UIInterfaceOrientationMask = .landscapeRight if !self.disableAutoRotation { orientations = .all } return orientations } func cameraSessionStartedRunning(_ session:AVCaptureSession?) { DispatchQueue.main.asyncAfter(deadline: .now(), execute: { /* * HELP::: This code does something only when debug directly from XCode, * not when directly launching the app on device!!!! */ cameraSessionRunning = true if #available(iOS 16.0, *) { UIView.performWithoutAnimation { self.setNeedsUpdateOfSupportedInterfaceOrientations() } } else { // Fallback on earlier versions UIViewController.attemptRotationToDeviceOrientation() } self.layoutInterfaceForOrientation(self.windowOrientation) }) }
Topic: UI Frameworks SubTopic: UIKit Tags:
Replies
4
Boosts
2
Views
2.7k
Activity
Sep ’22
What does "apps linked on or after iOS 15.4" mean?
I am unable to understand the sentence "Default is YES for all apps linked on or after iOS 15.4"found in Apple's documentation. What does it actually mean? Does it mean that the default value is YES for app running on iOS 15.4 or later? Or does it mean it is yes if the app is built with iOS 15.4 SDK or later? Or is it something else?
Replies
1
Boosts
0
Views
860
Activity
Sep ’22
iOS 16 mismatch between windowScene & UIViewController interfaceOrientation
This is another strange issue on iOS 16, and one among the many woes that cause autoRotation problems on the platform. At the app startup time, there is a mismatch between -[UIViewController interfaceOrientation] (now deprecated), -[UIViewController supportedInterfaceOrientations] (which returns .landscapeRight), and -[windowScene interfaceOrientation].  public var windowOrientation: UIInterfaceOrientation {         return view.window?.windowScene?.interfaceOrientation ?? .unknown     }  override func viewDidLayoutSubviews() {         super.viewDidLayoutSubviews()      layoutInterfaceForOrientation(windowOrientation)     }  override var supportedInterfaceOrientations: UIInterfaceOrientationMask {         return .landscapeRight Putting a breakpoint in viewDidLayoutSubviews reveals that windowOrientation is portrait while interfaceOrientation is .landscapeRight. Is there anyway this can be fixed or any workaround possible?
Topic: UI Frameworks SubTopic: UIKit Tags:
Replies
0
Boosts
0
Views
607
Activity
Sep ’22
XCode 14 SwiftUI dyld symbol not found
I get this error when I run my code on an iOS 14 device using XCode 14. dyld: Symbol not found: _$s7SwiftUI15GraphicsContextV4fill_4with5styleyAA4PathV_AC7ShadingVAA9FillStyleVtF Referenced from: ****** Expected in: /System/Library/Frameworks/SwiftUI.framework/SwiftUI I do not get any errors when I run the same code on an iOS 15 or iOS 16 device. How do I resolve this issue?
Replies
1
Boosts
0
Views
1.7k
Activity
Sep ’22
Workaround for iOS 16 Autorotation bugs
iOS 16 has serious bugs in UIKit without any known workarounds, so much that I had to remove my app from sale. Obviously I am affected and am desperate to know if anyone has found any workaround or if UIKit Engineers can tell me any workarounds. To summarise, the issue is calling setNeedsUpdateOfSupportedInterfaceOrientations shortly (within 0.5 seconds) after app launch doesn't trigger autorotation. It does trigger autorotation when the device is launched from the debugger but not when the app is launched directly. Maybe the debugger incurs some delay that is perhaps sufficient to trigger autorotation? I have filed FB11516363 but need a workaround desperately so as to get my app back on AppStore.
Replies
0
Boosts
0
Views
1.8k
Activity
Sep ’22
AVAudioEngine exception - required condition is false format.sampleRate == hwFormat.sampleRate
I see in Crashlytics few users are getting this exception when connecting the inputNode to mainMixerNode in AVAudioEngine: Fatal Exception: com.apple.coreaudio.avfaudio required condition is false: format.sampleRate == hwFormat.sampleRate Here is my code: self.engine = AVAudioEngine() let format = engine.inputNode.inputFormat(forBus: 0) //main mixer node is connected to output node by default engine.connect(self.engine.inputNode, to: self.engine.mainMixerNode, format: format) Just want to understand how can this error occur and what is the right fix?
Replies
2
Boosts
1
Views
3.4k
Activity
Aug ’22
AVFoundation crash in getting power levels from Audio channel
@AVFoundation engineers, my users am seeing the following crash which I can not reproduce at my end. *** -[__NSArrayI objectAtIndexedSubscript:]: index 2 beyond bounds [0 .. 1] Fatal Exception: NSRangeException 0 CoreFoundation 0x99288 __exceptionPreprocess 1 libobjc.A.dylib 0x16744 objc_exception_throw 2 CoreFoundation 0x1a431c -[__NSCFString characterAtIndex:].cold.1 3 CoreFoundation 0x4c96c CFDateFormatterCreateStringWithAbsoluteTime 4 AVFCapture 0x6cad4 -[AVCaptureConnection getAvgAudioLevelForChannel:] All I am doing is this:  func updateMeters() {         var channelCount = 0         var decibels:[Float] = []         let audioConnection = self.audioConnection         if let audioConnection = audioConnection {             for audioChannel in audioConnection.audioChannels {                 decibels.append(audioChannel.averagePowerLevel)                 channelCount = channelCount + 1             }         }          What am I doing wrong?
Replies
2
Boosts
0
Views
711
Activity
Aug ’22
UITextView contentInset default animation
I have this code to adjust UITextView when keyboard is about to be displayed. @objc func keyboardWillShow(notification: NSNotification) { if let rectValue = notification.userInfo?[UIResponder.keyboardFrameEndUserInfoKey] as? NSValue { let keyboardSize = rectValue.cgRectValue.size let contentInsets: UIEdgeInsets = UIEdgeInsets(top: 0, left: 0, bottom: keyboardSize.height - view.safeAreaInsets.bottom, right: 0) textView.contentInset = contentInsets textView.scrollIndicatorInsets = contentInsets } } I see setting contentInset automatically creates a scrolling animation (after the keyboard appears fully) that makes the text at the cursor visible. The animation happens automatically and there is no way to disable it. I want to scroll to a given location in the textView sometimes when the keyboard is presented (preferably, animating it along with keyboard appearance). The implicit contentInset animation makes it impossible however. First the keyboard animates, then contentInset animates, and now only can I animate to my chosen location in textView. This is awkward. I am wondering what is the right way to achieve it?
Topic: UI Frameworks SubTopic: UIKit Tags:
Replies
0
Boosts
0
Views
630
Activity
Jul ’22
UICollectionViewFlowLayout disable dynamic sizing
I have a UICollectionViewFlowLayout assigned to UICollectionView. It's delegate method returns fixed CGSize in sizeForItemAtIndexPath. The problem is if UICollectionViewCell contains UIImageView or any other dynamically sized view with autolayout constraints that match leading, trailing, top, bottom to contentView, the cell resizes depending on the size of image in the imageView. Is it possible to get fixed size cells with UICollectionViewFlowLayout? I tried setting intrinsicContentSize for UIImageView in storyboard but it doesn't work.
Topic: UI Frameworks SubTopic: UIKit Tags:
Replies
0
Boosts
0
Views
425
Activity
Jun ’22
Adding UILabel to UIContentViewCell disturbs it's size
I have a UICollectionViewCell defined in storyboard which has a UILabel added to it's contentView. Collection view uses a flow layout and I return a fixed size of cell in flowlayout delegate as follows: let sizeOfItem = CGFloat(210.0) func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { return CGSize(width: sizeOfItem, height: sizeOfItem) } I added the following constraint for UILabel in storyboard and the cell automatically starts resizing itself to match the text size in UILabel. This is not what I want. I want the cell to be fixed size and label to autoshrink instead. I even tried setting contentHuggingPriority of label to lowest value (i.e. 1). This stops the cell from auto-shrinking if the text in label is small. But the cell grows when the text is bigger. I don't want this to happen either. I want the cell to remain fixed size and label to adapt it's font and be constrained within the cell.
Replies
0
Boosts
0
Views
597
Activity
Jun ’22
Implementing Tone Curves using Metal/Core Image
I am trying to develop tone curves filter using Metal or Core Image as I find CIToneCurve filter is having limitations (number of points are atmost 5, spline curve it is using is not documented, and sometimes output is a black image even with 4 points). Moreover it's not straightforward to have separate R,G,B curves independently. I decided to explore other libraries that implement tone curve and the only one that I know is GPUImage (few others borrow code from the same library). But the source code is too cryptic to understand and I have [doubts] about the manner in which it is generating look up texture (https://stackoverflow.com/questions/70516363/gpuimage-tone-curve-rgbcomposite-filter). Can someone explain how to correctly implement R,G,B, and RGB composite curves filter like in Mac Photos App?
Replies
1
Boosts
1
Views
2k
Activity
May ’22
UITextView rich text editing
I need to implement a text editor using UITextView that supports: Bold/Italic/Underline Color,Font,font size changes Paragraph alignment List format (bullets, numbers, etc.) Custom selection of text anywhere in the text view and change the properties So far I have managed to do it without NSTextStorage but it seems I am hitting limits. For instance, to change font, I use UIFontPickerViewController and change the font as follows: func fontPickerViewControllerDidPickFont(_ viewController: UIFontPickerViewController) { if let selectedFontDesc = viewController.selectedFontDescriptor { let font = UIFont(descriptor: selectedFontDesc, size: selectedFontDesc.pointSize) self.selectedFont = font self.textView.typingAttributes = [NSAttributedString.Key.foregroundColor: self.selectedColor ?? UIColor.white, NSAttributedString.Key.font: self.selectedFont ?? UIFont.preferredFont(forTextStyle: .body, compatibleWith: nil)] if let range = self.textView.selectedTextRange, let selectedFont = selectedFont { let attributedText = NSMutableAttributedString(attributedString: self.textView.attributedText) let location = textView.offset(from: textView.beginningOfDocument, to: range.start) let length = textView.offset(from: range.start, to: range.end) let nsRange = NSRange(location: location, length: length) attributedText.setAttributes([NSAttributedString.Key.font : selectedFont], range: nsRange) self.textView.attributedText = attributedText } } } This works but the problem is it resets the color of the selected text and other properties. I need to understand a way in which the existing attributed of the text under selection are not disturbed. I suspect the way to do is with using NSTextStorage but I can't find anything good on internet that explains the right use of NSTextStorage to achieve this.
Replies
1
Boosts
0
Views
1.7k
Activity
May ’22
AVPlayer display on external screen transform
I have an AVPlayerLayer and AVPlayer setup for playback on external screen as follows: var player = AVPlayer() playerView.player = player       player.usesExternalPlaybackWhileExternalScreenIsActive = true  player.allowsExternalPlayback = true playerView is just a UIView that has AVPlayerLayer as it's main layer. This code works and automatically starts displaying and playing video on external screen. The thing is I want an option to invert the AVPlayerLayer on the external screen. I tried setting transform on playerView but that is ignored on the external screen. How do I gain more control on the external screen window? I also tried to manually add playerView to external screen window and set player.usesExternalPlaybackWhileExternalScreenIsActive = true I can also display AVPlayerLayer manually this way. But again, setting a transform on this screen has no effect on external display. So it may also be a UIKit issue.
Replies
1
Boosts
0
Views
1.3k
Activity
May ’22