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

UIKit Documentation

Posts under UIKit tag

717 Posts
Sort by:
Post not yet marked as solved
2 Replies
1k Views
I'm facing a weird situation in my app. When keyboard shows up and I click on microphone icon for dictation, the "Enable Dictation?" alert shows up but disappears quickly before I can tap on any option. How do I find out what is wrong in my code or how do I fix it?
Posted
by
Post not yet marked as solved
1 Replies
1.4k Views
I needed an infinite canvas for my app which is basically a drawing board where one can draw things using pen. So, I thought of having a very large custom UIView inside a UIScrollView. And in the custom view, I could keep drawing things. But, I ended up with a warning saying something like below and nothing drawn on screen. [<CALayer: 0x5584190> display]: Ignoring bogus layer size (50000, 50000) Which means, I can't have such a big CALayer to draw things. Now, solution? alternative? Then comes CATiledLayer. I made my large UIView backed by CATiledLayer now. After having a proper levelOfDetails and levelOfDetailsBias value, things worked like charm. Until I ended up facing another problem. Since, CATiledLayer caches drawing in different zoom levels if I try to scale the view after changing the drawing content the cached drawings appear and then the new contents get drawn. I don't find an option to invalidate caches in different levels. All the solutions I came across leads me to clear the entire contents of the CATiledLayer on drawing content change which won't help again. Do I miss something here? Is there a way with which I can clear caches at different levels? Or is there any other solutions which could solve my need? Can someone help me with this?
Post not yet marked as solved
7 Replies
2.2k Views
Hi, I'm testing one of my app on iOS 14 with Xcode 12 beta 3 (12A8169g) and I have a problem with my storyboards. Xcode give me this error for all the storyboards that contain a split view controller: An internal error occurred. Editing functionality may be limited. The log generated by the Xcode "Report a bug" button say: Exception name: NSInvalidArgumentException Exception reason: UITabBarController is unsupported as viewController for -[UISplitViewController setViewController:forColumn:] in Primary column It worked correctly on Xcode 12 beta 2. Has anyone encountered the same problem and found a way to fix it? Thank you
Posted
by
Post not yet marked as solved
8 Replies
3.1k Views
I have a collection view with UICollectionViewDiffableDataSource, which has class PHAssetVisualAssetsPickerItem as it’s ItemIdentifierType. When I create instance of NSDiffableDataSourceSnapshot with the same items that dataSource already has, and then apply it, I see that collection view blinks even tho nothing changed. It actually blinks no matter what new snapshot is. My investigation led to a fact that methods == (Equatable) and hasher(into:) (Hashable) are not called on items if items are classes. If I change them to structs, methods are called, dataSource understands what to do, nothing blinks. https://www.icloud.com/iclouddrive/0vnB3auwp0ShEvPQmpVOAy6fg#ApplySnapshotIndexPaths Here is the code where you can simply change HashableType to either class or struct and see that collectionView update looks different when you tap button.
Posted
by
Post not yet marked as solved
8 Replies
9.1k Views
I have noticed that in iOS 14 the UIPickerView has by default a light grey background on the selected Row like shown here. https://developer.apple.com/design/human-interface-guidelines/ios/controls/pickers/ I noticed also that pickerView.showsSelectionIndicator is deprecated on iOS 14. Is there a way to change the background color to white and add separators to achieve a pre iOS 14 UIPickerView style? Thank you
Post not yet marked as solved
3 Replies
5.2k Views
I am using Xcode Version 12.0 (12A7208) with… picker.preferredDatePickerStyle = .wheels I have tried: picker.setValue(UIColor.white, forKeyPath: "textColor") // crash and … picker.tintColor = UIColor.white // no change and … UILabel.appearance(whenContainedInInstancesOf: [UIDatePicker.self]).textColor = UIColor.white // no change
Posted
by
Post not yet marked as solved
3 Replies
4.2k Views
When I set : tableView.contentInset = UIEdgeInsets(top: 20, left: 0, bottom: 60, right: 0) The large title not show(small title instead of) when app first run, and it's right when I change contentInset's top to zero. I setup large title by this code: navigationController?.navigationBar.prefersLargeTitles = true I run it on iOS 13 is good, only break on iOS 14.
Posted
by
Post not yet marked as solved
8 Replies
4.8k Views
Is it possible to present UIMenu programmatically in UIButton or UIBarButton? I have custom logic where I'd like to show that menu. I couldn't find any solution.
Posted
by
Post not yet marked as solved
2 Replies
2.9k Views
In our app, we display contacts in UITableView. Let us say I have 300 contacts in my AddressBook, and all of them will be displayed in this table. Below this table, I have a UIButton to perform some action like invite selected contacts. With Voice Over enabled, when I get to the UITableView, it doesn't let me to proceed to the UIButton, unless I go over all 300 contacts. Is there a solution to override this and make it more friendly to the visually impaired users?
Posted
by
Post marked as solved
4 Replies
2.4k Views
I'm getting this message in console: [Assert] Attempted to call -cellForRowAtIndexPath: on the table view while it was in the process of updating its visible cells, which is not allowed. Make a symbolic breakpoint at UITableViewAlertForCellForRowAtIndexPathAccessDuringUpdate to catch this in the debugger and see what caused this to occur. Perhaps you are trying to ask the table view for a cell from inside a table view callback about a specific row? Table view: <UITableView: 0x10c04a000; frame = (0 0; 414 659); clipsToBounds = YES; gestureRecognizers = <NSArray: 0x280262bb0>; layer = <CALayer: 0x280d302c0>; contentOffset: {0, 183.5}; contentSize: {414, 3068}; adjustedContentInset: {0, 0, 0, 0}; dataSource: <MyApp.MyDataSource: 0x282930ea0>> It happens when my table view is in editing mode, some cells are selected and are about to be reused (I'm scrolling the table and selected cells leave the visible area). I don't call -cellForRowAtIndexPath: or visibleCells directly in my code. Here's the stack trace when this happens: Thread 1 Queue : com.apple.main-thread (serial) #0 0x0000000185303650 in UITableViewAlertForCellForRowAtIndexPathAccessDuringUpdate () #1 0x0000000185303378 in -[UITableView _cellForRowAtIndexPath:usingPresentationValues:] () #2 0x00000001852f1bb0 in -[UITableView _updateSelectionGroupingForCell:atIndexPath:] () #3 0x00000001852f1e78 in -[UITableView _updateSelectionGroupingForVisibleCells] () #4 0x00000001852af9d0 in -[UITableViewCell showSelectedBackgroundView:animated:] () #5 0x00000001852b045c in -[UITableViewCell setSelected:animated:] () #6 0x00000001852adf5c in -[UITableViewCell prepareForReuse] () #7 0x000000018530b2b4 in -[UITableView _dequeueReusableViewOfType:withIdentifier:] () #8 0x000000018530b908 in -[UITableView _dequeueReusableCellWithIdentifier:forIndexPath:usingPresentationValues:] () #9 0x000000018530b764 in -[UITableView dequeueReusableCellWithIdentifier:forIndexPath:] () #10 0x000000010103a4cc in MyDataSource.tableView(_:cellForRowAt:) at /../MyDataSource.swift:87 #11 0x000000010103a9f4 in @objc MyDataSource.tableView(_:cellForRowAt:) () #12 0x00000001853241ec in -[UITableView _createPreparedCellForGlobalRow:withIndexPath:willDisplay:] () #13 0x00000001852eff84 in -[UITableView _updateVisibleCellsNow:] () #14 0x000000018530e394 in -[UITableView layoutSubviews] () #15 0x0000000185643d90 in -[UIView(CALayerDelegate) layoutSublayersOfLayer:] () #16 0x0000000185b59384 in -[CALayer layoutSublayers] () #17 0x0000000185b59858 in CA::Layer::layout_if_needed(CA::Transaction*) () #18 0x0000000185b6dff8 in CA::Layer::layout_and_display_if_needed(CA::Transaction*) () #19 0x0000000185ab3ee0 in CA::Context::commit_transaction(CA::Transaction*, double, double*) () #20 0x0000000185adf36c in CA::Transaction::commit() () #21 0x0000000185ae06fc in CA::Transaction::observer_callback(__CFRunLoopObserver*, unsigned long, void*) () #22 0x00000001826c3358 in CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION () #23 0x00000001826bd5c4 in __CFRunLoopDoObservers () #24 0x00000001826bdb74 in __CFRunLoopRun () #25 0x00000001826bd21c in CFRunLoopRunSpecific () #26 0x000000019973c784 in GSEventRunModal () #27 0x00000001850f6200 in -[UIApplication _run] () #28 0x00000001850fba74 in UIApplicationMain () #29 0x000000010111a824 in main at /.../MyApp/AppDelegate.swift:17 #30 0x000000018237d6c0 in start () This only happens in iOS 14.2, no such problem on iOS 13.7. Does it look like an UIKit bug? Does anyone know how to solve it?
Posted
by
Post not yet marked as solved
3 Replies
1.7k Views
My view has several textfields for register. The problem is when I focus on a textfield to update, the text and the caret in the textfield disappeared (but it still stores the value). The text value only appears after the textfield lost keyboard focus. This error happen with all the devices I have (iPhone 12, iPad), all the simulators I tried. The only thing that works fine is when I using the simulator, I typed in textfield by my Mac physical keyboard instead of simulator's onscreen keyboard. I'm new in iOS and Swift so please can you help me to resolve this. I could provide UI Hierarchy if needed
Posted
by
Post marked as solved
2 Replies
2.2k Views
I am writing a keyboard-extension, there are several buttons and these buttons have a text, therefor I am using localized strings. So the extension is always in the "correct" language. When opening the keyboard-extension with the "world"-button (pressing it long, so that the menu is shown) there is always a line below the name of the app showing "English". As far as I know this is the primary language, there is also one entry for "PrimaryLanguage" in the info.plist (NSExtension/NSExtensionAttributes, set to "en-US"). I tried to remove this entry, but after this the app does not start anymore. Is there a different way to remove this entry or is it possible to change it to the language of the localization?
Posted
by
Post not yet marked as solved
3 Replies
2.7k Views
I have been working with UIViewRepresentable a lot recently and noticed something that seems to be quite the flaw: There doesn't seem to be a clean way of passing data back to your swiftUI views in a performant way. Here is an example: struct MapWrapper: UIViewRepresentable { &#9;&#9;@Binding var centerCoordinate: CLLocationCoordinate2D &#9;&#9;init(centerCoordinate: Binding<CLLocationCoordinate2D>) { &#9;&#9;&#9;&#9;self._centerCoordinate = centerCoordinate &#9;&#9;} &#9;&#9;func makeUIView(context: Context) -> MKMapView { &#9;&#9;&#9;&#9;var mapView = MKMapView() &#9;&#9;&#9;&#9;mapView.delegate = context.coordinator &#9;&#9;&#9;&#9;return mapView &#9;&#9;} &#9;&#9; &#9;&#9;func updateUIView(uiView: MKMapView, context: Context) { &#9;&#9;&#9;&#9;// Updating the maps center coordinate triggers mapViewDidChangeVisibleRegion, which thus causes updateUIView to trigger again. &#9;&#9;&#9;&#9;uiView.centerCoordinate = centerCoordinate &#9;&#9;} &#9;&#9;func makeCoordinator() -> Coordinator { &#9;&#9;&#9;&#9;return Coordinator(parent: self) &#9;&#9;} &#9;&#9;class Coordinator: MKMapViewDelegate { &#9;&#9;&#9;&#9;var parent: MapWrapper &#9;&#9;&#9;&#9;init(parent: MapWrapper) { &#9;&#9;&#9;&#9;&#9;&#9;self.parent = parent &#9;&#9;&#9;&#9;} &#9;&#9;&#9;&#9;func mapViewDidChangeVisibleRegion(_ mapView: MKMapView) { &#9;&#9;&#9;&#9;&#9;&#9;// updating this variable causes a view reload, thus calling updateUIView, and eventually causing this delegate method to trigger again. &#9;&#9;&#9;&#9;&#9;&#9;parent.centerCoordinate = mapView.centerCoordinate } } As you can see from the above code, dragging the map anywhere would cause a loop. The only workaround I have found for this is to give your coordinator a "shouldUpdateState" Boolean variable. and set that prior to updating your bindings. Has this ever been addressed by apple anywhere? Or are we just expected to only modify our view state from the outside of a UIViewRepresentable?
Posted
by
Post not yet marked as solved
10 Replies
5.4k Views
** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Not possible to remove variable: 400: unknown var (bug!) with engine as delegate:0x283c8ed40{id: 33112} colIndex:32 from engine NSISEngine: 0x129248130{ delegate:0x12934eaa0 EngineVars:  0: objective{id: 33102} rowIndex:0  1: UIImageView:0x12924ec90.Height{id: 32592} rowIndex:1073741824  2: 0x280a04be0.marker{id: 32591} colIndex:1073741825  3: UIImageView:0x12924ec90.Width{id: 32807} rowIndex:1  4: 0x280dc35a0.posErrorMarker{id: 32871} colIndex:1  5: 0x280dc35a0.negError{id: 32872} rowIndex:88  6: 0x280dc3d80.posErrorMarker{id: 32873} colIndex:1073741826  7: 0x280dc3d80.negError{id: 32874} rowIndex:1073741825  8: UIImageView:0x129353f00.Width{id: 32594} rowIndex:2  9: 0x280979d60.marker{id: 32593} colIndex:3 10: 0x280dc1e60.posErrorMarker{id: 32875} colIndex:4 11: 0x280dc1e60.negError{id: 32876} rowIndex:3 12: UIImageView:0x129353f00.Height{id: 32822} rowIndex:1073741826 13: 0x280dc39c0.posErrorMarker{id: 32877} colIndex:1073741827 14: 0x280dc39c0.negError{id: 32878} rowIndex:1073741898 15: UIButton:0x1293540d0.Width{id: 32817} rowIndex:4 16: 0x280dc2040.posErrorMarker{id: 32879} rowIndex:93 17: 0x280dc2040.negError{id: 32880} colIndex:6 18: UIButton:0x1293540d0.Height{id: 32820} rowIndex:1073741827 19: 0x280dc3de0.posErrorMarker{id: 32881} rowIndex:96 20: 0x280dc3de0.negError{id: 32882} colIndex:1073741830 21: UILabel:0x129353300.Width{id: 32811} rowIndex:5 22: 0x280dc3e40.posErrorMarker{id: 32883} colIndex:44 23: 0x280dc3e40.negError{id: 32884} rowIndex:90 24: UILabel:0x129353300.Height{id: 32842} colIndex:1073741828 25: 0x280dc27c0.posErrorMarker{id: 32885} colIndex:1073741831 26: 0x280dc27c0.negError{id: 32886} rowIndex:1073741828 27: UILabel:0x129353c90.Width{id: 32840} rowIndex:6 28: 0x280dc1da0.posErrorMarker{id: 32887} colIndex:9 29: 0x280dc1da0.negError{id: 32888} rowIndex:97 30: UILabel:0x129353c90.Height{id: 32829} colIndex:1073741832 31: 0x280dc31e0.posErrorMarker{id: 32889} colIndex:1073741833 32: 0x280dc31e0.negError{id: 32890} rowIndex:1073741900 33: UIImageView:0x12934e490.Width{id: 32596} rowIndex:1073741905 34: UIImageView:0x12934e490.Height{id: 32597} colIndex:1073741844 35: 0x280963a70.marker{id: 32595} colIndex:11 36: 0x280dc2ee0.posErrorMarker{id: 32891} colIndex:12 37: 0x280dc2ee0.negError{id: 32892} rowIndex:8 38: 0x280dc1d40.posErrorMarker{id: 32893} colIndex:1073741835 39: 0x280dc1d40.negError{id: 32894} rowIndex:1073741830 40: UIButton:0x1293543b0.Width{id: 32832} rowIndex:9 41: 0x280dc1440.posErrorMarker{id: 32895} colIndex:0 42: 0x280dc1440.negError{id: 32896} rowIndex:1073741845 43: UIButton:0x1293543b0.Height{id: 32827} rowIndex:1073741831 44: 0x280dc3840.posErrorMarker{id: 32897} colIndex:1073741836 45: 0x280dc3840.negError{id: 32898} rowIndex:1073741829 46: UILabel:0x129353a20.Width{id: 32848} rowIndex:10 and another thousand or so lines. this crash occurs after I change the language and open the workout page to start a workout immediately, and sometimes on the second time, I open the workout page.
Posted
by
Post not yet marked as solved
2 Replies
1.2k Views
Good day together, I am already in despair, I would like to insert a button in the NavigationBar next to the NavigationBarTitle which also automatically shrinks or enlarges. The whole thing can be seen in the App Store under the menu item "search". There, when the user scrolls down, the search bar and the title is given as .inline but not the user button. I am currently trying to implement the whole thing in SwiftUI and can't find a solution. Is there already a solution for this or if someone has the exact documentation for this case I would be very grateful for it :). thank you very much!
Posted
by
Post not yet marked as solved
1 Replies
626 Views
I have an existing app which uses a JSON-based file format currently saved to Application Support (so not user visible). It only needs a single data store per-user. I would like to integrate it with iCloud to make this file available on other devices. Is it considered acceptable to use UIDocument on its own for loading/saving the single file? By this I mean without using UIDocumentBrowserViewController or another file picker. Just my app loading right into the main UI but using UIDocument to open/read/save/close the data file. I am hoping this would allow me to let UIDocument do most of the boilerplate work around NSFileCoordinator and NSFilePresenter. Can anyone confirm if this is a thing that is known to be OK? Or am I going against the frameworks here?
Posted
by
Post not yet marked as solved
8 Replies
26k Views
With the following code I get the warning below it: let rootController = UIApplication.shared.windows.filter {$0.isKeyWindow}.first?.rootViewController 'windows' was deprecated in iOS 15.0: Use UIWindowScene.windows on a relevant window scene instead How do I change the code above to work with UIWindowScene instead?
Post not yet marked as solved
2 Replies
1.6k Views
Hi, One of our users is having an issue with our iOS App hanging consistently. The trace produced is not always the same but some parts are consistent between hangs. We have not been able to reproduce on our end. One sample stack trace from user is: CrashReporter Key: bf76ea06932831ef2338cbe2b08c552b6140ef83 Hardware Model: iPhone12,3 Version: 100.0.0 Role: Foreground OS Version: iOS 14.6 App Hang: The app was terminated while unresponsive 0 libsystem_kernel.dylib ___psynch_cvwait 1 libsystem_pthread.dylib __pthread_cond_wait 2 Metal -[_MTLCommandBuffer waitUntilCompleted] 3 CoreImage CI::MetalContext::readback_bitmap(CI::Bitmap*, CI::swizzle_info) 4 CoreImage ____ZN2CI16image_get_bitmapEPNS_7ContextEPNS_5ImageE6CGRectP12CGColorSpacePNS_6BitmapEPKNS_17RenderDestinationE_block_invoke 5 CoreImage CI::recursive_tile(CI::RenderTask*, CI::Context*, CI::RenderDestination const*, char const*, CI::Node*, CGRect const&, CI::PixelFormat, CI::swizzle_info const&, CI::TileTask* ( block_pointer)(CI::ProgramNode*, CGRect)) 6 CoreImage CI::tile_node_graph(CI::Context*, CI::RenderDestination const*, char const*, CI::Node*, CGRect const&, CI::PixelFormat, CI::swizzle_info const&, CI::TileTask* ( block_pointer)(CI::ProgramNode*, CGRect)) 7 CoreImage CI::image_get_bitmap(CI::Context*, CI::Image*, CGRect, CGColorSpace*, CI::Bitmap*, CI::RenderDestination const*) 8 CoreImage -[CIContext render:toBitmap:rowBytes:bounds:format:colorSpace:] 9 CoreUI -[CUIShapeEffectStack _newFlattenedImageFromShapeCGImage:withScale:ciContext:blendOverImage:] 10 CoreUI -[CUICatalog imageByStylingImage:stylePresetName:styleConfiguration:foregroundColor:scale:] 11 UIKitCore -[UIImage _imageWithStylePresets:tintColor:traitCollection:] 12 UIKitCore -[UIImageView _renditionForSource:size:withCGImageProvider:lazy:] 13 UIKitCore -[_UIImageContentContextualEffect _renditionWithCGImageProvider:size:lazy:] 14 UIKitCore -[_UIImageContent renditionWithSize:scale:applyingEffect:] 15 UIKitCore -[_UIImageContent renditionApplyingEffect:] 16 UIKitCore -[_UIImageCGImageContent renditionApplyingEffect:] 17 UIKitCore -[_UIImageContentLayout _materializeContentsIfNeeded] 18 UIKitCore -[_UIImageContentLayout contentsMultiplyColor] 19 UIKitCore -[UIImageView _updateContentsMultiplyColorAndSwizzleFromLayout:] 20 UIKitCore -[UIImageView _setImageViewContents:] 21 UIKitCore -[UIImageView _updateState] 22 UIKitCore +[UIView(Animation) performWithoutAnimation:] 23 UIKitCore -[UIImageView _updateImageViewForOldImage:newImage:] 24 UIKitCore -[UIImageView setImage:] 25 UIKitCore -[UIButton _updateImageView] 26 UIKitCore -[UIButton layoutSubviews] 27 UIKitCore -[UIView(CALayerDelegate) layoutSublayersOfLayer:] 28 QuartzCore -[CALayer layoutSublayers] 29 QuartzCore CA::Layer::layout_if_needed(CA::Transaction*) 30 QuartzCore CA::Layer::layout_and_display_if_needed(CA::Transaction*) 31 QuartzCore CA::Context::commit_transaction(CA::Transaction*, double, double*) 32 QuartzCore CA::Transaction::commit() 33 QuartzCore CA::Transaction::observer_callback(__CFRunLoopObserver*, unsigned long, void*) 34 CoreFoundation ___CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ 35 CoreFoundation ___CFRunLoopDoObservers 36 CoreFoundation ___CFRunLoopRun 37 CoreFoundation _CFRunLoopRunSpecific 38 GraphicsServices _GSEventRunModal 39 UIKitCore -[UIApplication _run] 40 UIKitCore _UIApplicationMain 42 libdyld.dylib _start What could be causing the above? Thanks in advance for your help.
Posted
by
Post not yet marked as solved
2 Replies
1k Views
I want change display name of the app (the one which is displayed below the app icon on user's device). I do not intend to change the app's name or its bundle identifier. I know how to do it, but want to know if this will also affect the URL of my app on the app store? Reason I ask this is I already have published QR codes directing to my app on the app store. If changing the app's display name is also going to change these URLs, then I will need to publish new QR codes.
Posted
by
Post marked as solved
3 Replies
4.3k Views
Using addObserver func of NotificationCenter.default, subscribing to UIApplication.willEnterForegroundNotification does not work when the backgrounding is triggered from Notification Center (swipe down from top when app is active to get Notification Center).  It also seems that UIApplication.willResignActiveNotification is called twice, based on Print() logs, when Notification Center triggers the backgrounding. If you background the app via lock screen or manual swipe, or switch to another app, the UIApplication.willEnterForegroundNotification does get called, so it seems to be specific to Notification Center. UIApplication.willResignActiveNotification does fire correctly but then resuming the app never calls the appMovedToForeground func below: notificationCenter.addObserver(self, selector: #selector(appMovedToForeground), name: UIApplication.willEnterForegroundNotification,object: nil) occurs on: iOS 14.4.2, iPhone 11 & iOS 14.6, SE(2)
Posted
by