Construct and manage graphical, event-driven user interfaces for iOS or tvOS apps using UIKit.

Posts under UIKit tag

200 Posts
Sort by:

Post

Replies

Boosts

Views

Activity

Xcode 16: SwiftUI plain Button & UIImageView not working
It looks like Xcode 16 has changed this behaviour so I'm not sure if this is a bug or not. When a SwiftUI Button wraps a UIImageView and the button style is .plain the button doesn't work without setting isUserInteractionEnabled. struct ContentView: View { var body: some View { Button { print("Hello World!") } label: { UITestImage() } .buttonStyle(.plain) } } struct UITestImage: UIViewRepresentable { func makeUIView(context: Context) -> UIImageView { let view = UIImageView() // view.isUserInteractionEnabled = true // Fix view.image = UIImage(systemName: "plus") view.contentMode = .scaleAspectFit view.setContentCompressionResistancePriority(.defaultLow, for: .horizontal) view.setContentCompressionResistancePriority(.defaultLow, for: .vertical) view.layoutMargins = .zero return view } public func updateUIView(_ uiView: UIImageView, context: Context) {} } This feels unexpected, is this a bug?
1
1
81
1d
Add 30 frames per secons in assetWriter
Hello, I have converted UIImage to CVPixelBuffer. I am creating a video writing app. In some cases, the same CVPixelBuffer should last in the video for 2 seconds or more. However, I need to add 30 CVPixelBuffers per second because the video, to work on social media, must be 30 frames per second. The problem is that whenever I try to add frames to long videos, like 50-minute videos, it gives an error. The error is something like "Operation cannot be completed". Give me an example of a loop to add 30 CVPixelBuffers per second to a currently written video. Example: while true { if videoInput.isReadyForMoreMediaData { break } if videoInput.isReadyForMoreMediaData, let buffer = videoProvider.getNextFrame() { adaptor.append(buffer, withPresentationTime: CMTime(value: 1, timescale: 30)) } } I await your response.
0
0
84
1d
Inner UIScrollView and outer UIPanGestureRecognizer
Hi, If there are nested UIScrollViews, they will work together nicely; when the inner scroll view reaches the end of contentSize, the outer scroll view will start scrolling. Can we do the same with inner UIScrollView and outer UIView that has UIPanGestureRecognizer? I’ve tried using UIGestureRecognizerDelegate and return true in gestureRecognizer(_:shouldRecognizeSimultaneouslyWith:) but that will scroll the inner UIScrollView and fire the outer UIPanGestureRecognizer at the same time. Thanks!
1
0
74
2d
UIPasteControl Button Appearing Disabled but Still Pasting Content
Hi everyone, I've implemented a UIPasteControl in my iOS app using the following code: func displayPasteControl() { if #available(iOS 16.0, *) { let pasteControlConfig = UIPasteControl.Configuration() let newPasteControlButton = UIPasteControl(configuration: pasteControlConfig) self.inputContainerView.addSubview(newPasteControlButton) newPasteControlButton.isEnabled = true // Set constraints for this button newPasteControlButton.translatesAutoresizingMaskIntoConstraints = false newPasteControlButton.topAnchor.constraint(equalTo: self.originalPasteView.topAnchor, constant: 0).isActive = true newPasteControlButton.centerXAnchor.constraint(equalTo: self.inputContainerView.centerXAnchor).isActive = true newPasteControlButton.widthAnchor.constraint(equalTo: self.originalPasteView.widthAnchor, multiplier: 0.5).isActive = true newPasteControlButton.bottomAnchor.constraint(equalTo: self.originalPasteView.bottomAnchor, constant: 0).isActive = true newPasteControlButton.target = self.inputTextView } } I call this function in viewWillAppear: override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) displayPasteControl() } Sometimes, I've noticed that the UIPasteControl button appears in a disabled state visually, but when I press it, the content from the clipboard is still pasted. I checked the state of UIPasteControl and it indicates that it is in an enabled state. For context, the UIPasteControl target is set to a UITextView (self.inputTextView). Has anyone experienced this issue or have any idea why this might be happening? Any help would be appreciated! Thank you!
0
0
35
2d
uialertviewcontroller presented reset's my tableview cells, font size / attributed text (iOS18)
when presenting an uialertviewcontroller either an actionsheet or alert it seems to have some weird interaction with my tableview cells. For example, i have custom font sizes a user can set so when im loading my cell i set the font size. It looks good on load but the second i preset a uialertviewcontroller it 'reset's all the cells to the default interface builder set fontsize. Some cells i use attributed text programmatically and that all gets reset as well to 'default' interface builder label settings. Its very odd. this is in iOS 18 b1. Funny enough it seems like every beta 1 (if i recall maybe in iOS 17 or iOS 16) it did the same thing there attributed text would like 'reset' its very odd. I have a hunch this is a bug and filed a feedback, but curious if there are any workarounds, or simply just wait until its fixed :D . Thanks all !
3
0
94
2d
Mimic TV App back button in UIKit
Hi In my application I'm trying to recreate the behaviour of the back button in the Apple TV app on iOS. What I'm looking for is a way to have a material background but also making it possible to animate (with an interruptible animation) the transition when the user scrolls down in a scroll view. When searching around there seems to be 2 hacks which doesn't solve my problem. Either you add a static image for the back button, which doesn't solve any of the points I mentioned before. The other hack is to stop using the back button in the UINavigationBar and start leveraging the left button instead, which I don't want because you loose the swipe back gesture. Can you just pinpoint me what API I could use to get a similar look and feel?
0
0
68
2d
UIPasteControl sometimes disappear
Problem Our app use UIPasteControl for people taps to place pasteboard contents in UITextView. It worked fine at first, but recently received a lot of user feedback and the button suddenly disappeared This problem usually occurs when an App switches between the front and back More Information When the button disappears, we find that the child view of the UIPasteControl control which name _UISlotView has a size of zero. we use UIKit and AutoLayout,limit button size (100, 36) let config = UIPasteControl.Configuration() config.displayMode = .labelOnly config.cornerStyle = .fixed config.baseForegroundColor = .white config.baseBackgroundColor = .black config.cornerRadius = 18 let btn = UIPasteControl(configuration: config) pasteBtn = btn addSubview(pasteBtn) pasteBtn.snp.makeConstraints { make in make.trailing.equalTo(-20) make.bottom.equalTo(-10) make.size.equalTo(CGSize(width: 100, height: 36)) } UI view information <UIPasteControl: 0x107dda810; frame = (0 0; 100 36); layer = <CALayer: 0x3010ff000>> (lldb) po [0x107dda810 subviews] <__NSSingleObjectArrayI 0x30152ff00>( <_UISlotView: 0x107dea630; frame = (0 0; 100 36); userInteractionEnabled = NO; layer = <CALayer: 0x3010eb460>> ) anyone meet before? is there a workaround?
2
0
77
3d
Show a UIMenu on double-tap?
Is there a way to programmatically show a UIMenu on iOS on a double-tap event? I have an app that's been around for over a decade, so there are some UX patterns that I'm reluctant to mess around with. There is a view in my app with the following properties: Tapping the view once focuses it and brings it to the front Double-tapping it shows a view controller as a sheet, with several operations you can perform on that object Instead of the sheet, I'd like to move to context menus - they look better, and they're more familiar for users. Obviously, adding a context menu for long-press is straightforward (just use UIContextMenuInteraction). But there does not seem to be a way to show the context menu on double-tap. I've discovered that you can use UIButton with showsMenuAsPrimaryAction to show the menu on single-tap, but that doesn't quite work for me. My users expect a single tap to do something else (focus the view) and will be annoyed if single taps start showing menus instead. So, is there a way to show a context menu on double tap in iOS?
1
0
92
3d
SwiftUI Tap Gestures Not Responding in SwiftUI View After UIKit Interactive Transition Cancelled
I am using a custom UINavigationController with a custom pop animation and an interactive transition. The custom navigation controller works well for standard UIKit view controllers. However, when I push a UIHostingController that hosts a SwiftUI view, the SwiftUI view becomes unresponsive to tap gestures if the interactive transition is cancelled. The issue seems to occur specifically after the interactive transition is started and then cancelled. This is interactive transition code class CustomPopAnimator: NSObject, UIViewControllerAnimatedTransitioning { func transitionDuration(using transitionContext: UIViewControllerContextTransitioning?) -> TimeInterval { return 0.3 } func animateTransition(using transitionContext: UIViewControllerContextTransitioning) { let containerView = transitionContext.containerView guard let fromView = transitionContext.view(forKey: .from), let toView = transitionContext.view(forKey: .to) else { return } containerView.insertSubview(toView, belowSubview: fromView) let screenWidth = UIScreen.main.bounds.width toView.transform = CGAffineTransform(translationX: -screenWidth / 3, y: 0) UIView.animate(withDuration: transitionDuration(using: transitionContext), animations: { fromView.transform = CGAffineTransform(translationX: screenWidth, y: 0) toView.transform = .identity }) { finished in fromView.transform = .identity toView.transform = .identity fromView.isUserInteractionEnabled = true transitionContext.completeTransition(!transitionContext.transitionWasCancelled) } } } class CustomInteractiveTransition: UIPercentDrivenInteractiveTransition { var hasStarted = false var shouldFinish = false override func cancel() { super.cancel() reset() } override func finish() { super.finish() reset() } private func reset() { hasStarted = false shouldFinish = false } } @objc class CustomNavigationController: UINavigationController, UINavigationControllerDelegate { private let customAnimator = CustomPopAnimator() private let customInteractiveTransition = CustomInteractiveTransition() override func viewDidLoad() { super.viewDidLoad() delegate = self setupGesture() } private func setupGesture() { let edgeSwipeGesture = UIScreenEdgePanGestureRecognizer(target: self, action: #selector(handleEdgeSwipe(_:))) edgeSwipeGesture.edges = .left view.addGestureRecognizer(edgeSwipeGesture) } @objc private func handleEdgeSwipe(_ gesture: UIScreenEdgePanGestureRecognizer) { let translation = gesture.translation(in: view) let progress = translation.x / view.bounds.width switch gesture.state { case .began: customInteractiveTransition.hasStarted = true popViewController(animated: true) case .changed: customInteractiveTransition.shouldFinish = progress > 0.5 customInteractiveTransition.update(progress) case .ended: customInteractiveTransition.hasStarted = false customInteractiveTransition.shouldFinish ? customInteractiveTransition.finish() : customInteractiveTransition.cancel() case .cancelled: customInteractiveTransition.hasStarted = false customInteractiveTransition.cancel() default: break } } func navigationController(_ navigationController: UINavigationController, animationControllerFor operation: UINavigationController.Operation, from fromVC: UIViewController, to toVC: UIViewController) -> UIViewControllerAnimatedTransitioning? { return operation == .pop ? customAnimator : nil } func navigationController(_ navigationController: UINavigationController, interactionControllerFor animationController: UIViewControllerAnimatedTransitioning) -> UIViewControllerInteractiveTransitioning? { return customInteractiveTransition.hasStarted ? customInteractiveTransition : nil } func navigationController(_ navigationController: UINavigationController, didShow viewController: UIViewController, animated: Bool) { if let hostingController = viewController as? AIMAHostingController<SwiftUIView> { DispatchQueue.main.async { hostingController.view.setNeedsLayout() hostingController.view.layoutIfNeeded() } } } } SwiftUI code struct SwiftUIView: View { var body: some View { VStack { Spacer() Text("Hello, World!") .id("123") .background(Color.green) .padding() .onTapGesture { print("===onclick") } Spacer() } } } let hostingController = UIHostingController(rootView: SwiftUIView()) navigationController?.pushViewController(hostingController, animated: true)
0
0
97
3d
"UIDevice.current.batteryLevel" is always "0" in macOS Sonoma 14.4
I recently updated to macOS Sonoma 14.4 and now UIDevice.current.batteryLevel is always 0. Code to reproduce: import SwiftUI struct ContentView: View { @State private var monitoringEnabled = UIDevice.current.isBatteryMonitoringEnabled; @State private var batteryLevel = UIDevice.current.batteryLevel; var body: some View { VStack { Text("Battery Monitoring Enabled: " + String(monitoringEnabled)) Text("Battery Level: " + String(batteryLevel)) Button("Toggle Monitoring") { monitoringEnabled = !monitoringEnabled; UIDevice.current.isBatteryMonitoringEnabled = monitoringEnabled; batteryLevel = UIDevice.current.batteryLevel; } } .padding() } } Run the above on a macOS 14.4 target, click "Toggle Monitoring", and you'll see battery level is reported as 0: I also see the following error in my app logs when running on macOS 14.4: Error retrieving battery status: result=-536870207 percent=0 hasExternalConnected=1 isCharging=0 isFullyCharged=0 This code displays the expected battery level when running on an actual iOS device:
2
0
616
4d
UIButton.ConfigurationUpdateHandler slow in UITableView cell [UIButton.Configuration, UIButtonConfiguration]
If you run the following UIKit app and tap on the button, you can see that it only updates its color if you hold on it for a bit, instead of immediately (as happens in the second app) (iOS 17.5, iPhone 15 Pro simulator, Xcode 15.4). This app consists of a view controller with a table view with one cell, which has a CheckoutButton instance constrained to its contentView top, bottom, leading and trailing anchors. The checkout button uses UIButton.Configuration to set its appearance, and update it based on its state. import UIKit class ViewController: UIViewController { let tableView = UITableView() let checkoutButton = CheckoutButton() override func viewDidLoad() { super.viewDidLoad() // table view setup view.addSubview(tableView) tableView.frame = view.bounds tableView.autoresizingMask = [.flexibleHeight, .flexibleWidth] tableView.dataSource = self tableView.register(UITableViewCell.self, forCellReuseIdentifier: "cell") } } extension ViewController: UITableViewDataSource { func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 1 } func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) cell.contentView.addSubview(checkoutButton) checkoutButton.translatesAutoresizingMaskIntoConstraints = false NSLayoutConstraint.activate([ checkoutButton.topAnchor.constraint(equalTo: cell.contentView.topAnchor), checkoutButton.bottomAnchor.constraint(equalTo: cell.contentView.bottomAnchor), checkoutButton.leadingAnchor.constraint(equalTo: cell.contentView.leadingAnchor), checkoutButton.trailingAnchor.constraint(equalTo: cell.contentView.trailingAnchor) ]) return cell } } class CheckoutButton: UIButton { override init(frame: CGRect) { super.init(frame: frame) var configuration = UIButton.Configuration.plain() var attributeContainer = AttributeContainer() attributeContainer.font = .preferredFont(forTextStyle: .headline) attributeContainer.foregroundColor = .label configuration.attributedTitle = .init("Checkout", attributes: attributeContainer) self.configuration = configuration let configHandler: UIButton.ConfigurationUpdateHandler = { button in switch button.state { case .selected, .highlighted: button.configuration?.background.backgroundColor = .systemCyan case .disabled: button.configuration?.background.backgroundColor = .systemGray4 default: button.configuration?.background.backgroundColor = .systemBlue } } self.configurationUpdateHandler = configHandler } required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") } } In this second app, instead, the selection of the button is immediately reflected in its appearance: import UIKit class ViewController: UIViewController { let button = CheckoutButton() override func viewDidLoad() { super.viewDidLoad() view.addSubview(button) button.translatesAutoresizingMaskIntoConstraints = false NSLayoutConstraint.activate([ button.centerXAnchor.constraint(equalTo: view.centerXAnchor), button.centerYAnchor.constraint(equalTo: view.centerYAnchor), button.widthAnchor.constraint(equalToConstant: 300), button.heightAnchor.constraint(equalToConstant: 44) ]) } } class CheckoutButton: UIButton { override init(frame: CGRect) { super.init(frame: frame) var configuration = UIButton.Configuration.plain() var attributeContainer = AttributeContainer() attributeContainer.font = .preferredFont(forTextStyle: .headline) attributeContainer.foregroundColor = .label configuration.attributedTitle = .init("Checkout", attributes: attributeContainer) self.configuration = configuration let configHandler: UIButton.ConfigurationUpdateHandler = { button in switch button.state { case .selected, .highlighted: button.configuration?.background.backgroundColor = .systemCyan case .disabled: button.configuration?.background.backgroundColor = .systemGray4 default: button.configuration?.background.backgroundColor = .systemBlue } } self.configurationUpdateHandler = configHandler } required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") } } This app consists of a view controller with just a button: no table view unlike in the first app. How do I make the button show its selection as soon as it's tapped, no matter if it's in a table view cell or on its own?
1
0
124
5d
How to: Compositional layout with self-sizing rows of N columns where the height of each item is set to the tallest item in its row
Paging Steve Breen! 😄 I've seen this question asked a zillion times but I've never seen an answer. Is it possible to configure compositional layout to give you a grid of N columns (say 2 or 3) where each item in each row/group self-size their height, but the heights of those items are then set to be the height of the tallest item in their row. This is easy to do if you ignore the self-sizing requirement (just use a fixed or absolute item height), but on the surface this doesn't even appear to be possible if you require self-sizing. What I've Tried Configuring a layout where the items are set to a fractional height of 1.0 and their group is set to an estimated height (ex: 100). I was hoping compositional layout would interpret this as, "Please self-size the height of the group and make each item 100% of that height." Unfortunately, compositional layout just uses the estimate you provide for the height as the actual height and no self-sizing occurs at all. Sad panda. 🐼 Use visibleItemsInvalidationHandler to attempt to identify which items share a row and reset their heights to be the height of the tallest item in that row. Sadly, the handler doesn't really have access to the data it needs to do this, nor is it allowed to change frames, nor is it called on the first layout pass, nor does it appear to be supported at all for layouts containing estimated items. In fact, if you try to use it with layouts that support self-sizing, you'll get this error message: [UICompositionalLayout] note: the section invalidation handler cannot currently mutate visible items for layouts containing estimated items. Please file an enhancement request on UICollectionView. Wishing upon a star. Oh, and I also filed a radar asking: FB11776888 Here's a visual aid: I have a little test program as well, but unfortunately I can't upload it here. Happy to share if it would be helpful. Here are a couple snippets: #1 // This doesn't work     private func makeLayout1() -> UICollectionViewCompositionalLayout {         // Item         let itemSize = NSCollectionLayoutSize(widthDimension: .fractionalWidth(0.5), heightDimension: .fractionalHeight(1))         let item = NSCollectionLayoutItem(layoutSize: itemSize)         // Group         let groupSize = NSCollectionLayoutSize(widthDimension: .fractionalWidth(1), heightDimension: .estimated(100))         let group = NSCollectionLayoutGroup.horizontal(layoutSize: groupSize, repeatingSubitem: item, count: 2)         group.interItemSpacing = .fixed(10)         // Section         let section = NSCollectionLayoutSection(group: group)         return UICollectionViewCompositionalLayout(section: section)     } #2 // This self-sizes the heights of the items, but allows the items in each row to be different heights rather than providing any way to constrain them to the height of the tallest self-sized item in each row     private func makeLayout2() -> UICollectionViewCompositionalLayout {         // Item         let itemSize = NSCollectionLayoutSize(widthDimension: .fractionalWidth(0.5), heightDimension: .estimated(100))         let item = NSCollectionLayoutItem(layoutSize: itemSize)         // Group         let groupSize = NSCollectionLayoutSize(widthDimension: .fractionalWidth(1), heightDimension: .estimated(100))         let group = NSCollectionLayoutGroup.horizontal(layoutSize: groupSize, repeatingSubitem: item, count: 2)         group.interItemSpacing = .fixed(10)         // Section         let section = NSCollectionLayoutSection(group: group)         return UICollectionViewCompositionalLayout(section: section)     } Options? My guess is that compositional layout simply doesn't support layouts that require a "partial second pass" per group, where the frames of the items can be updated based on information collected during self-sizing the other items in the group (to, for example, force them all to a common height, or align them top/bottom/centered within their group). If that's the case (not supported), I would love a suggestion for where I might override the layout to provide this capability. Thank you! ❤️
4
5
3.1k
1w
iOS floating caret position
Hello, On iOS it is possible to use the keyboard spacebar to move the caret while editing text. The user has to longpress on the spacebar, and then the keyboard would turn into a trackpad that moves around a floating caret. Is there a way to get the position of the caret while the user uses this space bar navigation? And by the position I mean the position in an app or in a frame? Are there any other events that this action can send out? Thanks a lot!
1
0
197
1w
Expandable UIView inside Navigation Bar can't be clicked/tapped
Hello Team we facing a problem with a UIView inside of a Navigation Bar what we need to achieve is to place a UIView (SwiftUI Wrapper) on the middle of the Navigation bar Here's how it looks like right now that's already complete, but now the problem that we are facing is that the View is not detecting the clicks/taps on the 'dates and 'travelers' here's the Code for the View private lazy var sharedUIPlaybackView: UIView = { let containerView = UIView().withAutoLayout() containerView.backgroundColor = .red containerView.styleBorder(color: .systemPink, width: 1) let propertySearchCriteria = PropertySearchCriteriaBuilder(hotelSearchParameters: viewModel.hotelSearchParameters).criteria var swiftUIView: SwiftUIView<LodgingPlaybackWrapper>! = nil swiftUIView = SwiftUIView( LodgingPlaybackWrapper(propertySearchCriteria: propertySearchCriteria, playbackUpdateNotificationSender: nil, componentHandler: { [weak self] componentId in self?.componentReady(componentId) }), viewDidLayoutSubviewsCallback: { [weak self] in let newHeight = swiftUIView.frame.size.height if newHeight != self?.sharedUIPlaybackViewHeightConstraint?.constant { self?.sharedUIPlaybackViewHeightConstraint?.constant = newHeight self?.additionalSafeAreaInsets.top = 200 } } ).withAutoLayout().withAccessibilityIdentifier("searchPlayback") sharedUIPlaybackViewHeightConstraint = containerView.heightAnchor.constraint(equalToConstant: 0) sharedUIPlaybackViewHeightConstraint?.isActive = true swiftUIView.backgroundColor = .blue swiftUIView.styleBorder(color: .orange, width: 1) containerView.addSubview(swiftUIView) containerView.addConstraints([ swiftUIView.leadingAnchor.constraint(equalTo: containerView.leadingAnchor, constant: Spacing.spacing4x), swiftUIView.trailingAnchor.constraint(equalTo: containerView.trailingAnchor, constant: -Spacing.spacing4x) ]) self.view.bringSubviewToFront(swiftUIView) swiftUIView.isUserInteractionEnabled = true swiftUIView.layer.zPosition = 1 return containerView }() my first suspicion was that the this part of the code was not expanding correctly viewDidLayoutSubviewsCallback: { [weak self] in let newHeight = swiftUIView.frame.size.height if newHeight != self?.sharedUIPlaybackViewHeightConstraint?.constant { self?.sharedUIPlaybackViewHeightConstraint?.constant = newHeight self?.additionalSafeAreaInsets.top = 200 } } but after I place border and background colors on the views was clear for me that it was expanding properly, so I added some modifiers for the view like swiftUIView.isUserInteractionEnabled = true swiftUIView.layer.zPosition = 1 but didn't work, I'm asking for a solution and different point of view for the code to be more cleaner and do the best implementation posible. This Navigation bar should be treated as a custom Navigation Bar, or it is good for us to expand and treat the Navigation bar like this? (expanding and adding a Custom View) thanks in advance to anyone who read this. here's the View Hierarchy
1
0
186
1w
Disable the keyboard suggestions for a UITextField
I have a UITableView with a bunch of UITextFields in 'em. (in a custom UITableViewCell subclass) For every UITextField I have set: cell.textField.textContentType = .none I even tried: cell.textField.inlinePredictionType = .no // iOS >= 17 and: cell.textField.keyboardType = .default cell.textField.autocorrectionType = .no cell.textField.spellCheckingType = .no cell.textField.autocapitalizationType = .none Still, when I tap in one of them, I get a 'suggestion' in a bar just above the Keyboard that I can fill in my phone number. How can I prevent that? I am using: xcode 15.4, iOS 17.5.1. Compiling for iOS 13.0 and later.
2
0
240
1w
UIDocumentPickerViewController -> OneDrive/G-Drive -> NSFileCoordinator
Hey, I'm not sure I'm even in the correct ballpark - trying to allow my app to download largish videos from user's OneDrive and G-Drive to app Is it correct to use NSFileCoordinator in this way? How do I report progress as it downloads the video (is it possible?) Is it correct to dismiss the picker like this? anything else wrong (or, like is....any of it correct? :) it's sort of working with my contrived examples (I created new personal G-drive / Onedrive accounts, and copied vids up there), but...when I use a file from our corporate OneDrive, from shared folder, I get: "NSCocoaErrorDomain Code=3328 "The requested operation couldn’t be completed because the feature is not supported." Is this the NSFileProvider extension (Microsoft's) complaining? public func documentPicker(_ controller: UIDocumentPickerViewController, didPickDocumentsAt urls: [URL]) {     guard  let url = urls.first else {       return     }     let isSecurityScoped = url.startAccessingSecurityScopedResource()     print("(#function) - iSecurityScoped = (isSecurityScoped)")     print("(#function) - document at (url)")     let filename = String(UUID().uuidString.suffix(6)) + "_" +  url.lastPathComponent     let newURL = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0].appendingPathComponent(filename)          let readingIntent = NSFileAccessIntent.readingIntent(with: url, options: .withoutChanges)     fileCoordinator.coordinate(with: [readingIntent], queue: queue) { error in       defer {         if isSecurityScoped {           url.stopAccessingSecurityScopedResource()         }       }       if let error = error {         print("(#function) - (error)")         return       }       let safeURL = readingIntent.url       do {         let fileData = try Data(contentsOf: safeURL)         try fileData.write(to: newURL, options: .atomic)         print("(#function) - SUCCESS - newURL = (newURL)")       } catch {         print("(#function) - NOOOOO - (error)")       }     }     controller.dismiss(animated: true)   }
1
1
577
1w
UITableView setTableHeaderView
我遇到了一个问题,当一个View是tableview的tableHeaderview时,我把View重新嵌套一层重新设置给tableHeaderview,这个View不展示 代码如下: UIView *view = [UIView new]; tableView.tableHeaderview = view; UiView *otherView = [UIview new]; otherView addSubview:view]; tableView.tableHeaderview = otherView; 这个时候view不展示了。 根据调用栈看,设置tableHeaderview后,view执行了一次removeFromSuperview,从otherView中消失了。 所以想了解一下,当设置新的tableHeaderview,对旧的HeaderView是怎么处理的?
1
0
193
3w