Follow up to this thread, does adjustsFontSizeToFitWidth also follow the same thinking? Is it assumed that if we use a font style, this doesn't need to be set in a UIButton if we're using UIButtonConfiguration?
UIKit
RSS for tagConstruct and manage graphical, event-driven user interfaces for iOS or tvOS apps using UIKit.
Post
Replies
Boosts
Views
Activity
Hello!
I've tested/implemented TipKit in SwiftUI and UIKit but it seems that the close, i.e. X, button doesn't work in UIKit but does in SwiftUI. Not sure if this is a bug or I have to do something different about it in UIKit.
Testing with Xcode 15 Beta 8
Thanks!
I have some visualisation-heavy AUv3's, and the goal is not to perform graphics-intensive tasks if the plugin window is not opened inside the host app (such as Logic Pro).
On iOS, this is easily accomplished by the viewWillAppear, etc overrides. But on macOS, it seems these overrides are not called every time the user opens / closes the plugin windows in the host application.
I did try some alternate methods, like trying to traverse the view / controller hierarchy, or make use of the window property, to no avail.
What substitute mechanism could I use to determine visibility status of an AUv3 on macOS?
Thanks in advance,
Zoltan
Hi, I adopted in my app the new default style for the status bar where it switches between light and dark themes depending on the color of the content beneath. It works great until I hide the status bar and show it again. From that point onwards, the status bar will be stuck on the dark or light theme, depending on the app's theme.
This happens as well if the status bar is initially hidden on startup. In that case, the default behavior never works.
I filed an issue (FB13222217), and as of now I didn't find a workaround except never hiding the status bar on my app. I attached a super minimalist example project there, just a scroll view with black and white views and nothing more.
This happens on SwiftUI and UIKit as well.
I hope the issue can be addressed and will appreciate if anyone has a workaround for this to let me know.
Thanks!
Activity image for custom activity is blank ever since iOS 17 release ,compiled in Xcode 15. The image being sent is 180x180 px. Works fine in iOS 16 running earlier Xcodes.
Attached a image of the issue showing blank icons (mail and messages are the custom activities)
Anyone facing the issue?
I've run into a problem that has been giving me fits for a while and have yet to be able to find a solution. We have a Catalyst app that uses a three-pane UISplitView. The middle and third panes show the navigation bar of the UINavigationController hosted in each pane.
However, when building under Xcode 15, the navigation bar is not shown in the middle pane when running under macOS 14. It is shown, as expected, when the app is run under prior versions of macOS. It also appears as it should under macOS 14 if the app is built with Xcode 14.
If you push another view controller onto the navigation controller's stack with the animate flag set to true, the navigation bar will appear. When you go back to the root controller, the navigation bar is present as it should be. However, if you push the controller with the animate flag set to false, the navigation bar does not appear.
I've been able to reproduce this in an isolated test app with just the relevant components. The first screenshot at the end is from a test app that illustrates the problem. The second screenshot shows what it should look like (and does look like under macOS 13).
It should be noted that UINavigationBar.appearance().preferredBehavioralStyle = .pad is set.
If any Apple folk would kindly like to look into this, I created a feedback for it: FB13260893. The feedback entry has a sample app, screenshots, and even a screen recording demonstrating the problem.
Has anyone else run into this or does anyone have any suggestions for a fix/workaround?
Thanks,
Kevin
Prior to macOS 14, a Catalyst app could present a UIAlertController as a popover, just as you can on the iPad. While this still works on the iPad, the presentation on macOS now uses the same style as the iPhone.
The UIAlertController's popoverPresentationController property is always nil, no matter how it is configured.
Doe anyone know of a way to restore the prior behavior under Sonoma?
My App development language is only Arabic. I am using textField to Login User, whenever user long pressed, ToolTip showed up. Problem is with tool tip text it is flipped. My device language is English
After updating to Mac OS Sonoma, we have encountered compatibility issues with our iPad-designed application, specifically with the AirPrint functionality, when it is run on MacOS. The AirPrint feature stopped working properly through UIPrintInteractionController.shared.
We have noticed that when we compile the application using Catalyst, the AirPrint functionality is restored and works as expected. However, this solution is not viable for us due to the restrictions associated with the frameworks we are utilizing.
We are seeking alternative solutions, and any help or guidance would be highly appreciated to resolve this issue and ensure a seamless and uninterrupted user experience in our application.
STEPS TO REPRODUCE
Create an app for ipad with just a button and this code
var str = "TEST"
let printInfo = UIPrintInfo(dictionary:nil)
printInfo.outputType = .general
printInfo.jobName = "Report"
printInfo.orientation = .portrait
let printController = UIPrintInteractionController.shared
printController.printInfo = printInfo
printController.showsNumberOfCopies = false
printController.showsPageRange = false
printController.showsNumberOfCopies = false
let formatter = UIMarkupTextPrintFormatter(markupText: str)
formatter.contentInsets = UIEdgeInsets(top: 72, left: 72, bottom: 72, right: 72)
printController.printFormatter = formatter
printController.present(animated: true, completionHandler: nil)
2.Run it on a MacOS with Sonoma, there is no error on console or anything but it don't work.
-If you run it with Catalyst it just works when adding the Printing permission of App Sandbox in Signing & Capabilities.
It appears that we are not able to reorder rows in our tables when running our iOS/iPadOS app under Mac Catalyst. It appears that all the delegate methods are returning true indicating the row can be moved and edited. The reordering handles appear in editing move and the row can be moved around (also using drag and drop) but the user interface is not indicating that the row can be dropped to be reordered. It's as if the proposed destination path is being rejected. I tried setting up that delegate method (thinking that maybe the default for that is messed up on Mac Catalyst) but it had no effect. Every table in our system performs this way.
Here is a link to an example video that shows the table view not working:
https://onsongapp.s3.amazonaws.com/Reordering%20Example.mp4
Please advise if there is something else that needs to be implemented or changed for Mac Catalyst to properly handle table cell reordering.
With Mac Catalyst, in Big Sur and Monterey, you could use UICommandTagShare as the property list for a UICommand in combination with activityItemsConfiguration and itemProvidersForActivityItemsConfiguration to allow a "Share" submenu to appear in a menu in your app (for instance, under the File menu like many other apps).
Starting in Ventura, this submenu no longer appears with that same code, and instead the UICommandTagShare command in the menu now just displays "Share" with no submenu, which triggers a UIActivityViewController to appear in the main window.
Is there any way to still allow a Share submenu to work in Ventura and beyond with Mac Catalyst? Thanks so much for any help!
Hello! I've been digging into this for a little bit now, and am hitting something of a wall. Our app is crashing occasionally, and googling the crash yields literally 0 results.
Tl;dr: Something related to adaptivePresentationStyle(for:traitCollection:) is resulting in our app crashing.
Context
In our app, we have a custom UIPresentationController that we use to present a small sheet of content overlaying other app content - similar to a UISheetPresentationController with a medium-ish size. So we have a custom UIViewController to present, and it conforms to the UIAdaptivePresentationControllerDelegate protocol. We also have custom present and dismiss animators.
The crash
However, we seem to be running into a really odd crash. I've attached a crash report as well, but here's what one sees in xcode on reproducing the crash:
The _computeToEndFrameForCurrentTransition block is nil inside the _transitionViewForCurrentTransition block, value of outerStrongSelf currently : <XxxYyyyyyZzz.PopupPresentationController: 0x12d017a40>. This most likely indicates that an adaptation is happening after a transtion cleared out _computeToEndFrameForCurrentTransition. Captured debug information outside block: presentationController : <XxxYyyyyyZzz.PopupPresentationController: 0x12d017a40> presentedViewController : <XxxYyyyyyZzz.SomeViewController: 0x12d03a690> presentingViewController : <UINavigationController: 0x12a817400>
2023-09-25_08-02-33.6523_-0500-7d355cd4a86427213389765ef070a777c4b4aaa3.crash
Whenever we present one of these view controllers, things work just fine. When we try to present another one though, if someone is aggressively changing the phone orientation, the app crashes. This crash occurs somewhere in between dismissing the old VC and presenting the new one. It occurs before I ever hit any breakpoints in the "present" animator for the second view controller.
I've narrowed things down a bit, and by commenting out our implementation of adaptivePresentationStyle(for:traitCollection:), the crash can't be reproduced anymore. The downside there being that the app no longer functions how we want it to. Our definition of that function (which causes crashes) looks like this:
public func adaptivePresentationStyle(for controller: UIPresentationController, traitCollection: UITraitCollection) -> UIModalPresentationStyle {
guard forceUsingFullScreenIfCompact else {
return .none
}
return traitCollection.verticalSizeClass == .compact ? .overFullScreen : .none
}
A bit more testing, and it seems like if that function returns the same thing consistently, nothing crashes. Are we not allowed to put conditional logic in this function?
In the crash, we can see that it occurs due to a failing assertion internal to UIPresentationController:
Last Exception Backtrace:
0 CoreFoundation 0x1afa28cb4 __exceptionPreprocess + 164 (NSException.m:202)
1 libobjc.A.dylib 0x1a8abc3d0 objc_exception_throw + 60 (objc-exception.mm:356)
2 Foundation 0x1aa1b2688 -[NSAssertionHandler handleFailureInFunction:file:lineNumber:description:] + 172 (NSException.m:251)
3 UIKitCore 0x1b1d05610 __80-[UIPresentationController _initViewHierarchyForPresentationSuperview:inWindow:]_block_invoke + 2588 (UIPresentationController.m:1594)
4 UIKitCore 0x1b21f1ff4 __56-[UIPresentationController runTransitionForCurrentState]_block_invoke_3 + 300 (UIPresentationController.m:1228)
The question
This all leads us to wonder if we're doing something wrong, or if there could be a bug in one of the iOS APIs that we're consuming. Thus, posting here. Does anyone have any insight into how this could be occurring, or has seen this before and has ideas? Thanks!
Miscellaneous info
We target iOS 14+
We've seen this issue in debug and release builds from Xcode 14 and 15
We see the issue on users with iOS 15+, though it could be occurring on 14 in just incredibly low numbers
This is a re-post of https://developer.apple.com/forums/thread/738257, because I accidentally closed that out as resolved
I have a view in storyboard, with a tableView and a coloured UIView.
The UIView is declared after tableView, so it appears on top of tableView.
However, it appears semi transparent over the tableView.
In addition, I cannot set its alpha channel to values other than 1 or 0 (e.g., 0.9)
But if I create the view programmatically, the view if fully opaque as expected.
What am I missing ?
In ios17 and above, I can detect when swiftUI app goes into and out of background using:
@Environment(\.scenePhase) private var phase
...
.onChange(of: phase) {
switch phase {
case .background:
print("entering background...")
case .active:
print("entering foreground...")
default: break
}
}
Is there a straightforward way to do this in SwiftUI for ios 16? I've found some examples using UIKit, but I am not that swift (sorry, couldn't resist) with that framework.
When a user updates their device to iOS 17 (any version) on a device with MDM, our app crashes but only on some device, not all. The same app runs fine on iOS 16. We cannot recreate the issue in-house and even our customers cannot reliably recreate the crash as it only happens on some devices and not others.
The crash we get is:
SIGABRT: UICollectionView internal inconsistency: missing final attributes for cell
Once the device gets this crash, the only way to fix it is to delete and reinstall the app and then everything works fine.
Anyone having a similar issue with iOS 17 and MDM?
I wanted to post this here in the hope that this will draw attention to what I think is a serious change in behavior that could negatively affect Catalyst apps in macOS 14.4.
Prior to macOS 14.4, when the completion handler was invoked from calling dismiss() to dismiss a presented view controller in a Catalyst app, the dismissed controller no longer appeared in the chain. That is to say that if the root view controller presents View Controller A, when View Controller A is dismissed, the root view controller's presentedViewController property is nil when the completion handler for dismiss() is called.
With macOS 14.4, this is no longer the case. If the root view controller presents View Controller A and then View Controller A is dismissed, the presentedViewController property of the root view controller still refers to Controller A when dismiss()'s completion handler is called.
The side effect of this change in behavior means that if you try to present another view controller from the completion handler of the one being dismissed, it will fail to show because the top most view controller in the chain is the controller being dismissed and presenting from it will result in nothing showing up because it is removed from the chain immediately after the completion handler is invoked. Before macOS 14.4, it the top of the chain would have been the controller that presented the controller that was dismissed, which is what you actually want.
This problem does not exist in the betas for iOS 17.4 or iPadOS 17.4. It appears to affect only Catalyst apps running under macOS 1.4.4.
I think this change in behavior has the potential to affect a number existing Catalyst apps and it may not be obvious to the user something is going wrong. It really should be fixed before macOS 14.4 is released to the public.
I've created a feedback with a sample Xcode project that demonstrates the problem (feedback number FB13622757).
We are using UIDocumentInteractionController to preview a pdf. When you navigate on your phone with the hardware keyboard and it focuses on the pfd preview, there is no way we can reach the buttons in the toolbar anymore like the share and done button. Is this a bug or is there a way to get to the navigation/toolbars? iOS17.0 iPhone14 sim and real device.
Hi, a few of my customers are facing a crash on using the app. I am unable to reproduce the issue myself. Can you please help. Here is the crash log of a user. Mine is a SwiftUI app.
Crash log of a user
In Xcode 15 and 14, I encounter the following error related to float max and min. This occurs within a React Native project, although it seems that React itself is not the cause of the error.
I am trying to self size DTAttributedTextContentView inside the collection cell based on its attributed text. The problem I face is that when I set attributedTextContentView width constraints like so:
attributedTextContentView.widthAnchor.constraint(lessThanOrEqualToConstant: 260)
it applies the whole constant width (in this case 260) to the textContentView, even if attributedString length is smaller than the width, leaving some extra space:
My question is, how to size the frame of DTAttributedTextContentView so that it just encloses the text that it contains?
Initially I used basic UITextView, but the scrolling of cells through collection view is not that smooth when there are multiple cells, and also it gives possibility to easy access the last line of the text inside, which I need for my app, so I would like to stick to DTAttributedTextContentView.
Here is the sample code for testing:
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
configureCollectionView()
}
// MARK: - Collection view setup
let collectionView: UICollectionView = {
let layout = UICollectionViewCompositionalLayout { (section, environment) -> NSCollectionLayoutSection? in
let itemSize = NSCollectionLayoutSize(widthDimension: .fractionalWidth(1.0), heightDimension: .estimated(10))
let item = NSCollectionLayoutItem(layoutSize: itemSize)
let group = NSCollectionLayoutGroup.vertical(layoutSize: itemSize, subitems: [item])
let section = NSCollectionLayoutSection(group: group)
section.interGroupSpacing = 5
return section
}
layout.configuration.scrollDirection = .vertical
let collectionView = UICollectionView(frame: .zero, collectionViewLayout: layout)
collectionView.register(ConversationCollectionViewCell.self, forCellWithReuseIdentifier: "ConversationCell")
return collectionView
}()
private func configureCollectionView() {
collectionView.dataSource = self
collectionView.backgroundColor = .brown
view.addSubview(collectionView)
collectionView.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
collectionView.leadingAnchor.constraint(equalTo: view.leadingAnchor),
collectionView.trailingAnchor.constraint(equalTo: view.trailingAnchor),
collectionView.topAnchor.constraint(equalTo: view.topAnchor),
collectionView.bottomAnchor.constraint(equalTo: view.bottomAnchor)
])
}
}
// MARK: - Collection Data Source
extension ViewController: UICollectionViewDataSource {
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return 10
}
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "ConversationCell", for: indexPath) as! ConversationCollectionViewCell
return cell
}
}
// MARK: - Collection View Custon Cell
final class ConversationCollectionViewCell: UICollectionViewCell, DTAttributedTextContentViewDelegate {
var mainCellContainerView = UIView()
var attributedTextContentView = DTAttributedTextContentView()
//MARK: - LIFECYCLE
override init(frame: CGRect) {
super.init(frame: frame)
setupmainCellContainerView()
setupAttributedTextContentView()
layoutIfNeeded()
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
// MARK: - UI STEUP
private func setupmainCellContainerView() {
contentView.addSubview(mainCellContainerView)
mainCellContainerView.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
mainCellContainerView.topAnchor.constraint(equalTo: contentView.topAnchor),
mainCellContainerView.bottomAnchor.constraint(equalTo: contentView.bottomAnchor),
mainCellContainerView.leadingAnchor.constraint(equalTo: contentView.leadingAnchor),
mainCellContainerView.trailingAnchor.constraint(equalTo: contentView.trailingAnchor),
])
}
private func setupAttributedTextContentView() {
mainCellContainerView.addSubview(attributedTextContentView)
attributedTextContentView.backgroundColor = .systemIndigo
attributedTextContentView.delegate = self
attributedTextContentView.sizeToFit()
let attributedString = NSAttributedString(string: "Simple message for testing purpose @", attributes: [
.font: UIFont(name: "HelveticaNeue", size: 17),
.foregroundColor: UIColor.white,
.paragraphStyle: {
let paragraphStyle = NSMutableParagraphStyle()
paragraphStyle.alignment = .left
paragraphStyle.lineBreakMode = .byWordWrapping
return paragraphStyle
}()
])
attributedTextContentView.attributedString = attributedString
attributedTextContentView.contentMode = .redraw
attributedTextContentView.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
attributedTextContentView.widthAnchor.constraint(lessThanOrEqualToConstant: 260),
attributedTextContentView.topAnchor.constraint(equalTo: mainCellContainerView.topAnchor),
attributedTextContentView.bottomAnchor.constraint(equalTo: mainCellContainerView.bottomAnchor),
])
}
}