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

UIKit Documentation

Posts under UIKit subtopic

Post

Replies

Boosts

Views

Activity

Xcode 14: [Assert] UINavigationBar decoded as unlocked for UINavigationController
In Xcode 14 RC, I'm seeing this in the Console: [Assert] UINavigationBar decoded as unlocked for UINavigationController, or navigationBar delegate set up incorrectly. Inconsistent configuration may cause problems. navigationController=<MasterNavigationController: 0x135016200>, navigationBar=<UINavigationBar: 0x134f0aec0; frame = (0 20; 0 50); opaque = NO; autoresize = W; layer = <CALayer: 0x600000380be0>> delegate=0x135016200 The above message displays exactly four times immediately at app launch (top of the console) then does not repeat. MasterNavigationController is the internal class for the app's navigation controller. It is in a Storyboard, with very minimal ObjC code. I am not setting any specific size for the nav bar. I don't remember seeing this in earlier builds of Xcode, but I can't swear to it that this is new. No assertion actually fires.
Topic: UI Frameworks SubTopic: UIKit Tags:
42
23
30k
Mar ’25
NSTextLineFragment crash - how to debug
We have crash reports as shown below that we haven't yet been able to repro and could use some help deubgging. My guess is that the app is giving a label or text view an attributed string with an invalid attribute range, but attributed strings are used in many places throughout the app, and I don't know an efficient way to track this down. I'm posting the stack trace here in hopes that someone more familiar with the internals of the system frameworks mentioned will be able to provide a clue to help narrow where I should look. Fatal Exception: NSRangeException NSMutableRLEArray objectAtIndex:effectiveRange:: Out of bounds 0 CoreFoundation 0x2d5fc __exceptionPreprocess 1 libobjc.A.dylib 0x31244 objc_exception_throw 2 Foundation 0x47130 blockForLocation 3 UIFoundation 0x2589c -[NSTextLineFragment _defaultRenderingAttributesAtCharacterIndex:effectiveRange:] 4 UIFoundation 0x25778 __53-[NSTextLineFragment initWithAttributedString:range:]_block_invoke 5 CoreText 0x58964 TLine::DrawGlyphsWithAttributeOverrides(TLineDrawContext const&, __CFDictionary const* (long, CFRange*) block_pointer, TDecoratorObserver*) const 6 CoreText 0x58400 CTLineDrawWithAttributeOverrides 7 UIFoundation 0x25320 _NSCoreTypesetterRenderLine 8 UIFoundation 0x24b10 -[NSTextLineFragment drawAtPoint:graphicsContext:] 9 UIFoundation 0x3e634 -[NSTextLineFragment drawAtPoint:inContext:] 10 UIFoundation 0x3e450 -[NSTextLayoutFragment drawAtPoint:inContext:] 11 UIKitCore 0x3e3098 __38-[_UITextLayoutFragmentView drawRect:]_block_invoke 12 UIKitCore 0x3e31cc _UITextCanvasDrawWithFadedEdgesInContext 13 UIKitCore 0x3e3040 -[_UITextLayoutFragmentView drawRect:] 14 UIKitCore 0xd7a98 -[UIView(CALayerDelegate) drawLayer:inContext:] 15 QuartzCore 0x109340 CABackingStoreUpdate_ 16 QuartzCore 0x109224 invocation function for block in CA::Layer::display_() 17 QuartzCore 0x917f0 -[CALayer _display] 18 QuartzCore 0x90130 CA::Layer::layout_and_display_if_needed(CA::Transaction*) 19 QuartzCore 0xe50c4 CA::Context::commit_transaction(CA::Transaction*, double, double*) 20 QuartzCore 0x5bd8c CA::Transaction::commit() 21 UIKitCore 0x9f3f0 _UIApplicationFlushCATransaction 22 UIKitCore 0x9c89c __setupUpdateSequence_block_invoke_2 23 UIKitCore 0x9c710 _UIUpdateSequenceRun 24 UIKitCore 0x9f040 schedulerStepScheduledMainSection 25 UIKitCore 0x9cc5c runloopSourceCallback 26 CoreFoundation 0x73f4c __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ 27 CoreFoundation 0x73ee0 __CFRunLoopDoSource0 28 CoreFoundation 0x76b40 __CFRunLoopDoSources0 29 CoreFoundation 0x75d3c __CFRunLoopRun 30 CoreFoundation 0xc8284 CFRunLoopRunSpecific 31 GraphicsServices 0x14c0 GSEventRunModal 32 UIKitCore 0x3ee674 -[UIApplication _run] 33 UIKitCore 0x14e88 UIApplicationMain also filed as FB16905066
3
0
178
Mar ’25
UIContextMenuInteraction not working if view is originally offscreen
I’m having a weird UIKit problem. I have a bunch of views in a UIScrollView and I add a UIContextMenuInteraction to all of them when the view is first loaded. Because they're in a scroll view, only some of the views are initially visible. The interaction works great for any of the views that are initially on-screen, but if I scroll to reveal new subviews, the context menu interaction has no effect for those. I used Xcode's View Debugger to confirm that my interaction is still saved in the view's interactions property, even for views that were initially off-screen and were then scrolled in. What could be happening here?
Topic: UI Frameworks SubTopic: UIKit Tags:
0
0
37
Mar ’25
update UIKit view when viewDidLayoutSubviewsCallback from swiftUI wrapper gets call
Hello team i notice that we have a problem in our app that every time the user opens a Textfield the app freezes when the keyboard appears, this behavior was tracked down and it's a UI breaking design on a UIView [this view it's expandable and is original size is 80] [when it gets expanded 206.33] this is the view code I change the colors to easy check the other's views created inside private lazy var sharedUIPlaybackView: UIView = { let containerView = UIView().withAutoLayout() let propertySearchCriteria = PropertySearchCriteriaBuilder(hotelSearchParameters: viewModel.hotelSearchParameters).criteria var swiftUIView: SwiftUIView&lt;LodgingPlaybackWrapper&gt;! = nil swiftUIView = SwiftUIView( LodgingPlaybackWrapper(propertySearchCriteria: propertySearchCriteria, playbackUpdateNotificationSender: playbackUpdateNotificationSender, componentHandler: { [weak self] componentId in self?.componentReady(componentId) }), viewDidLayoutSubviewsCallback: { [weak self] in let extraPadding = self?.playbackViewExtraPadding ?? Spacing.spacing8x let newHeight = swiftUIView.frame.size.height + extraPadding // if newHeight != self?.sharedUIPlaybackViewHeightConstraint?.constant { // self?.sharedUIPlaybackViewHeightConstraint?.constant = 206.33 // }else { // self?.sharedUIPlaybackViewHeightConstraint?.constant = 80 // } } ).withAutoLayout().withAccessibilityIdentifier("test") // sharedUIPlaybackViewHeightConstraint = containerView.heightAnchor.constraint(equalToConstant: 0) // sharedUIPlaybackViewHeightConstraint?.isActive = true containerView.backgroundColor = .blue swiftUIView.backgroundColor = .red containerView.addSubview(swiftUIView) containerView.addConstraints([ swiftUIView.topAnchor.constraint(equalTo: containerView.topAnchor, constant: playbackViewTopConstant), swiftUIView.leadingAnchor.constraint(equalTo: containerView.leadingAnchor, constant: Spacing.spacing4x), swiftUIView.trailingAnchor.constraint(equalTo: containerView.trailingAnchor, constant: -Spacing.spacing4x), swiftUIView.bottomAnchor.constraint(equalTo: containerView.bottomAnchor, constant: -Spacing.spacing3x), swiftUIView.heightAnchor.constraint(equalToConstant: 206.33) ]) return containerView }() old devs created this function viewDidLayoutSubviewsCallback to connect user interaction on the wrapper and used on UIKit. this is the part where the math on the function gets weird and messed up the code by crashing the view viewDidLayoutSubviewsCallback: { [weak self] in let extraPadding = self?.playbackViewExtraPadding ?? Spacing.spacing8x let newHeight = swiftUIView.frame.size.height + extraPadding if newHeight != self?.sharedUIPlaybackViewHeightConstraint?.constant { self?.sharedUIPlaybackViewHeightConstraint?.constant = newHeight } } ).withAutoLayout().withAccessibilityIdentifier("test") sharedUIPlaybackViewHeightConstraint = containerView.heightAnchor.constraint(equalToConstant: 0) sharedUIPlaybackViewHeightConstraint?.isActive = true I commented this math because is crashing the app and instead of giving a dynamical height I placed as a constant constraint as default height this is how I solved the problem of the UI, but I still need to update the view each time the user clicks and gets call by the method viewDidLayoutSubviewsCallback what can I do? I tried to add like a conditional on the method if newHeight == 80 { containerView.addConstraints([ swiftUIView.heightAnchor.constraint(equalToConstant: 80.0) ]) containerView.layoutIfNeeded() } else { containerView.addConstraints([ swiftUIView.heightAnchor.constraint(equalToConstant: 206.33) ]) containerView.layoutIfNeeded() } like this but it didn't work [this is how it looks with the constant value of 206.33] [when it gets open looks good]
2
0
216
Mar ’25
Vibrancy effect not applied to context menu UIImages rendered in template mode
Our Apple TV provides UIImages with renderingMode forced to .alwaysTemplate (the images are also configured with "Render As" to "Template image" in the Asset catalog) to UIActions as UIMenuElement when building a UICollectionView UIContextMenuConfiguration. Problem: these images are not displayed with vibrancy effect by the system. The issue does not occur with system images (SVG from SF Catalog). Here is a screenshot showing the issue with custom images ("Trailer" and "Remove from favourites"): I don't know the underlying implementation of the context menu items image but UIImageView already implements the tintColorDidChange() method and the vibrancy should work if the UIImage is rendered as template. According to my tests, the vibrancy is correctly applied when using Symbols sets instead of Images sets but I understand that custom images rendered as template should support it as-well, shouldn't they?
2
0
129
Mar ’25
Regarding errors with UIToolbar and UIBarButtonItem set to UITextField
I set UIToolbar and UIBarButtonItem to UITextField placed on Xib, but when I run it on iOS18 iPad, the following error is output to Xcode Console, and UIPickerView set to UITextField.inputView is not displayed. Error: this application, or a library it uses, has passed an invalid numeric value (NaN, or not-a-number) to CoreGraphics API and this value is being ignored. Please fix this problem. If you want to see the backtrace, please set CG_NUMERICS_SHOW_BACKTRACE environmental variable. Backtrace: <CGPathAddLineToPoint+71> <+[UIBezierPath _continuousRoundedRectBezierPath:withRoundedCorners:cornerRadii:segments:smoothPillShapes:clampCornerRadii:] <+[UIBezierPath _continuousRoundedRectBezierPath:withRoundedCorners:cornerRadius:segments:]+175> <+[UIBezierPath _roundedRectBezierPath:withRoundedCorners:cornerRadius:segments:legacyCorners:]+338> <-[_UITextMagnifiedLoupeView layoutSubviews]+2233> <__56-[_UITextMagnifiedLoupeView _updateCloseLoupeAnimation:]_block_invoke+89> <+[UIView(UIViewAnimationWithBlocksPrivate) _modifyAnimationsWithPreferredFrameRateRange:updateReason:animations:]+166> <block_destroy_helper.269+92> <block_destroy_helper.269+92> <__swift_instantiateConcreteTypeFromMangledName+94289> <block_destroy_helper.269+126> <+[UIView(UIViewAnimationWithBlocks) _setupAnimationWithDuration:delay:view:options:factory:animations:start:anima <block_destroy_helper.269+6763> <block_destroy_helper.269+10907> <-[_UITextMagnifiedLoupeView _updateCloseLoupeAnimation:]+389> <-[_UITextMagnifiedLoupeView setVisible:animated:completion:]+256> <-[UITextLoupeSession _invalidateAnimated:]+329> <-[UITextRefinementTouchBehavior textLoupeInteraction:gestureChangedWithState:location:translation:velocity: <-[UITextRefinementInteraction loupeGestureWithState:location:translation:velocity:modifierFlags:shouldCanc <-[UITextRefinementInteraction loupeGesture:]+701> <-[UIGestureRecognizerTarget _sendActionWithGestureRecognizer:]+71> <_UIGestureRecognizerSendTargetActions+100> <_UIGestureRecognizerSendActions+306> <-[UIGestureRecognizer _updateGestureForActiveEvents]+704> <_UIGestureEnvironmentUpdate+3892> <-[UIGestureEnvironment _updateForEvent:window:]+847> <-[UIWindow sendEvent:]+4937> <-[UIApplication sendEvent:]+525> <__dispatchPreprocessedEventFromEventQueue+1436> <__processEventQueue+8610> <updateCycleEntry+151> <_UIUpdateSequenceRun+55> <schedulerStepScheduledMainSection+165> <runloopSourceCallback+68> <__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__+17> <__CFRunLoopDoSource0+157> <__CFRunLoopDoSources0+293> <__CFRunLoopRun+960> <CFRunLoopRunSpecific+550> <GSEventRunModal+137> <-[UIApplication _run]+875> <UIApplicationMain+123> <__debug_main_executable_dylib_entry_point+63> 10d702478 204e57345 Type: Error | Timestamp: 2025-03-09 00:22:46.121407+09:00 | Process: FurusatoLocalCurrency | Library: CoreGraphics | Subsystem: com.apple.coregraphics | Category: Unknown process name | TID: 0x5c360 Unable to simultaneously satisfy constraints. Probably at least one of the constraints in the following list is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it. (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints) ( "<NSAutoresizingMaskLayoutConstraint:0x600002202a30 h=--& v=--& _UIToolbarContentView:0x7fc2c6a5b8f0.width == 0 (active)>", "<NSLayoutConstraint:0x600002175e00 H:|-(0)-[_UIButtonBarStackView:0x7fc2c6817b10] (active, names: '|':_UIToolbarContentView:0x7fc2c6a5b8f0 )>", "<NSLayoutConstraint:0x600002175e50 H:[_UIButtonBarStackView:0x7fc2c6817b10]-(0)-| (active, names: '|':_UIToolbarContentView:0x7fc2c6a5b8f0 )>", "<NSLayoutConstraint:0x6000022019f0 'TB_Leading_Leading' H:|-(8)-[_UIModernBarButton:0x7fc2a5aa8920] (active, names: '|':_UIButtonBarButton:0x7fc2a5aa84d0 )>", "<NSLayoutConstraint:0x600002201a40 'TB_Trailing_Trailing' H:[_UIModernBarButton:0x7fc2a5aa8920]-(0)-| (active, names: '|':_UIButtonBarButton:0x7fc2a5aa84d0 )>", "<NSLayoutConstraint:0x600002201e50 'UISV-canvas-connection' UILayoutGuide:0x600003b7d420'UIViewLayoutMarginsGuide'.leading == _UIButtonBarButton:0x7fc2f57117f0.leading (active)>", "<NSLayoutConstraint:0x600002201ea0 'UISV-canvas-connection' UILayoutGuide:0x600003b7d420'UIViewLayoutMarginsGuide'.trailing == UIView:0x7fc2a5aac8e0.trailing (active)>", "<NSLayoutConstraint:0x6000022021c0 'UISV-spacing' H:[_UIButtonBarButton:0x7fc2f57117f0]-(0)-[UIView:0x7fc2a5aa8330] (active)>", "<NSLayoutConstraint:0x600002202210 'UISV-spacing' H:[UIView:0x7fc2a5aa8330]-(0)-[_UIButtonBarButton:0x7fc2a5aa84d0] (active)>", "<NSLayoutConstraint:0x600002202260 'UISV-spacing' H:[_UIButtonBarButton:0x7fc2a5aa84d0]-(0)-[UIView:0x7fc2a5aac8e0] (active)>", "<NSLayoutConstraint:0x600002176f30 'UIView-leftMargin-guide-constraint' H:|-(0)-[UILayoutGuide:0x600003b7d420'UIViewLayoutMarginsGuide'](LTR) (active, names: '|':_UIButtonBarStackView:0x7fc2c6817b10 )>", "<NSLayoutConstraint:0x600002176e40 'UIView-rightMargin-guide-constraint' H:[UILayoutGuide:0x600003b7d420'UIViewLayoutMarginsGuide']-(0)-|(LTR) (active, names: '|':_UIButtonBarStackView:0x7fc2c6817b10 )>" ) Will attempt to recover by breaking constraint <NSLayoutConstraint:0x600002201a40 'TB_Trailing_Trailing' H:[_UIModernBarButton:0x7fc2a5aa8920]-(0)-| (active, names: '|':_UIButtonBarButton:0x7fc2a5aa84d0 )> Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger. The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKitCore/UIView.h> may also be helpful.
Topic: UI Frameworks SubTopic: UIKit Tags:
0
0
75
Mar ’25
Failing UI Test for new floating Tabbar iOS 18+
Xcode 16.1 iOS 18.1 iPad Air 13-inch (M2) I have created a completely new Xcode project with Swift and Storyboard. In Storyboard, I only have a tabBarController with two attached UIViewControllers. The code from the base project hasn't been changed at all. I created a UITest with a very simple premise. let app = XCUIApplication() override func setupWithError() throws { continueAfterFailure = false app.launch() } func testTabBarExistence() { let tabBar = app.tabBars.element(boundBy: 0) XCTAssertTrue(tabBar.waitForExistence(timeout: 5), "Tab bar should exist") } But this test always fails for iPad on iOS 18+, but it will succeed for anything lower (e.g. 17.5)
2
1
473
Mar ’25
detecting modifier keys using UITextFieldDelegate protocol
I have a UITextField in my application, and I want to detect all the keys uniquely to perform all relevant task. However, there is some problem in cleanly identifying some of the keys. I m not able to identify the backspace key press in the textField(_:shouldChangeCharactersIn:replacementString:) method. Also I don't know how to detect the Caps Lock key. I am intending to so this because I want to perform some custom handling for some keys. Can someone help me with what is the way of detecting it under the recommendation from apple. Thanks in advance. Note: checking for replacementString parameter in shouldChangeCharactersIn method for empty does not help for backspace detection as it overlaps with other cases.
Topic: UI Frameworks SubTopic: UIKit Tags:
0
0
112
Mar ’25
UINavigtionController as a child view leaves an unwanted gap
I have a situation where I need to add a UINavigationController as a child view controller within another view controller. When I do this, there is a gap between the bottom of the navigation controller's root view controller and the bottom of the navigation controller's own view. This happens even though I am constraining the navigation controller's view to the edges of its superview, not the safe areas. I'd really like to eliminate this gap, but nothing I have tried is working.
Topic: UI Frameworks SubTopic: UIKit Tags:
1
0
213
Mar ’25
Syntax Highlighting with TextKit 2
Based on this TextKit 2 demo project I thought that I could implement syntax highlighting by parsing syntax block tokens (e.g. comments like <!-- --> or /* */) in processEditing and storing their locations, and then actually applying the rendering with NSTextContentStorageDelegate in textContentStorage(_:textParagraphWith:) by checking the location of each paragraph against the store of syntax tokens. This sort of works except that the rendering is only updated for paragraphs which are changed. Is there a way to trigger NSTextContentStorage to re-fetch paragraphs in a given range? Or is this a totally misguided approach to the problem?
Topic: UI Frameworks SubTopic: UIKit Tags:
2
0
655
Mar ’25
SensorKit Data Not Retrieving
I have received permission from Apple to access SensorKit data for my app. I have granted all necessary permissions, but no data is being retrieved. The didCompleteFetch method is being called, but I’m unsure where to find event data like Device Usage and Ambient Light. Additionally, the didFetchResult method is never called. Could anyone please assist me in resolving this issue? Any guidance or troubleshooting steps would be greatly appreciated. import SensorKit class ViewController: UIViewController, SRSensorReaderDelegate { let store = SRSensorReader(sensor: .deviceUsageReport) override func viewDidLoad() { super.viewDidLoad() requestSensorAuthorization() } func requestSensorAuthorization() { var sensors: Set<SRSensor> = [ .accelerometer, .deviceUsageReport, .messagesUsageReport, .visits, .keyboardMetrics, .phoneUsageReport, .ambientLightSensor ] if #available(iOS 16.4, *) { sensors.insert(.mediaEvents) } SRSensorReader.requestAuthorization(sensors: sensors) { error in if let error = error { print("Authorization failed: \(error.localizedDescription)") } else { self.store.startRecording() self.requestSensorData() print("Authorization granted for requested sensors.") } } } func requestSensorData() { let fromTime = SRAbsoluteTime.fromCFAbsoluteTime(_cf: Date().addingTimeInterval(-60 * 60).timeIntervalSinceReferenceDate) let toTime = SRAbsoluteTime.fromCFAbsoluteTime(_cf: Date().timeIntervalSinceReferenceDate) let request = SRFetchRequest() request.from = fromTime request.to = toTime request.device = SRDevice.current store.fetch(request) store.delegate = self } func sensorReader(_ reader: SRSensorReader, didCompleteFetch fetchRequest: SRFetchRequest) { print("Fetch request completed: \(fetchRequest.from) to \(fetchRequest.to)") Task { do { let samples = try await reader.fetch(fetchRequest) print("Samples count: \(samples)") } catch { print("Error Fetching Data: \(error.localizedDescription)") } } } func sensorReader(_ reader: SRSensorReader, fetching fetchRequest: SRFetchRequest, didFetchResult result: SRFetchResult<AnyObject>) -> Bool { print(result) return true } }
0
0
144
Mar ’25
Strange behavior when pushing UIViewController
This is a very strange behavior when pushing vc that I have never seen since I started coding. The pushed ViewController is transparent and only navBarTitle is shown. After the push, you can't control anything unless you go back to the home screen. STEPS TO REPRODUCE Long press currency change button below.(currencyWrapper) Call selectCountry and this bug happens. SourceCode let currencyWrapper = UIView() private func configureCurrencyCard(){ //The strange behavior shows up after long pressing this currencyWrapper.backgroundColor = .white currencyWrapper.addTarget(self, action: #selector(changeCurrency)) currencyWrapper.setWidth(currencyChangeIcon.follow(by: 16, x: true)) currencyWrapper.setCenterX(w1/2) currencyWrapper.setHeight(currencyLabel.follow(by: 12, x: false)) currencyWrapper.roundToCircle(true) view.addSubview(currencyWrapper) } private func selectCountry(country: Country){ let vc = CountryViewController(country: country) vc.hidesBottomBarWhenPushed = true navigationController?.pushViewController(vc, animated: true) }
Topic: UI Frameworks SubTopic: UIKit Tags:
2
0
194
Mar ’25
Crash on removal of QLPreviewController and _EXRemoteViewController
I have a controller that displays a pdf using UIDocumentInteractionController as the presented view. When users open it up, it shows fine. User gets the app backgrounded and session timed out. After timed out, when the app is brought to foreground, I bring our loginVC by removing the old VC used to show the UIDocumentInteractionController. All the crashes are happening at this point. I am not able to reproduce it, but our alert systems show we have crashes happening. The code that shows the pdf is straight forward documentViewController = UIDocumentInteractionController() documentViewController?.delegate = self documentViewController?.url = url documentViewController?.presentPreview(animated: true) and we reset it to nil in delegate documentInteractionControllerDidEndPreview Based on the crash trace, it seems like the crash happens when our login VC replaces it and only when pdf was displayed. The reason of stressing ONLY because when we have other viewcontroller present and they are removed in a similar way, we do not see any issue. So we always replace first and then add a new one childViewController.willMove(toParent: nil) childViewController.viewIfLoaded?.removeFromSuperview() childViewController.removeFromParent() addChild(childViewController) view.addSubview(childViewController.view) childViewController.view.frame = view.bounds childViewController.didMove(toParent: self) Raised a ticket with Apple, but I haven't heard back, and it's been a month. Posting here in case anyone experiences the same and has any solutions. I saw some related posts, and solution was to remove the pdf the moment the app goes to the background, but I am trying to find some alternate solution if possible.
Topic: UI Frameworks SubTopic: UIKit
0
0
159
Mar ’25
Trouble using MKAnnotation on a MKMapView
Hi everyone, i'im having troubles using Annotation on a Map View. I have a a core data model called Location that conforms to NSManagedObject from CoreData and MKAnnotation form MapKit, and i'm trying to add an array of Location to a MKMview instance in a UIViewController class, by doing somethhing like this: mapView.addAnnotation(locations), but xcode compliants with a strange error which says Argument type '[Location]' does not conform to expected type 'MKAnnotation'. it's strange to me because my Location class conforms to MKAnnotation protocol and i implemented the protocol's methods (coordinate, title, subtitle). Please can anyone help me how to fix this issues. Thank you all
Topic: UI Frameworks SubTopic: UIKit Tags:
2
0
130
Mar ’25
Force rotation not working properly
We rotate the portrait to landscape then we force rotate to portrait app rotates but the screen seems to be divided into two parts My sample code class OrientationHelper { static func lockOrientation(_ orientation: UIInterfaceOrientationMask) { if let delegate = UIApplication.shared.delegate as? AppDelegate { delegate.orientationLock = orientation } } static func lockOrientation(_ orientation: UIInterfaceOrientationMask, andRotateTo rotateOrientation: UIInterfaceOrientation) { self.lockOrientation(orientation) DispatchQueue.main.async { UIDevice.current.setValue(rotateOrientation.rawValue, forKey: "orientation") UIViewController.attemptRotationToDeviceOrientation() } } } // Appdelegte var orientationLock = UIInterfaceOrientationMask.portrait func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask { return orientationLock }
Topic: UI Frameworks SubTopic: UIKit
2
0
218
Mar ’25
ActiveLabel
Hey Everyone, I can't see to ActiveLabel as it says there is no active module. Please help me. Thanks, Ben import UIKit import ActiveLabel protocol TweetCellDelegate: AnyObject { func handleProfileImageTapped(_ cell: TweetCell) func handleReplyTapped(_ cell: TweetCell) func handleLikeTapped(_ cell: TweetCell) } class TweetCell: UICollectionViewCell {
0
0
204
Mar ’25