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

UIKit Documentation

Posts under UIKit tag

1,029 Posts
Sort by:
Post not yet marked as solved
4 Replies
81 Views
Hello. I'd like to improve my keyboard focus experience on iPad in one of the usage scenarios of my app - browsing through two UICollectionViews in a master-detail pattern. I am able to navigate the master collection view with the arrow keys, and focus is indicated correctly; however, after selecting an item with the keyboard, which pushes the detail collection view on the same navigation stack, the focus indicator disappears and the following message appears in the console: [UIFocus] Starting to defer focus updates. followed by a symbolicated stack trace. At this point, the user has to tap one of the arrow keys so that the focus indicator reappears. In this case, if the user then exits the detail collection view, which reveals the master collection view, the item that was focused and selected on the master collection view will be indicated correctly. The console shows the following message: [UIFocus] Disabling focus deferral. followed once again by a symbolicated stack trace. Interestingly, the focus indicator also disappears after a period of time if the user leaves the app open and does not interact with it. In that case, the same message about starting to defer focus updates will appear, and the subsequent stack trace will contain an __NSFireTimer frame. My question would be - what are the criteria for focus deferral and how can I control its behavior? Thank you. Please let me know if I can add any relevant details to this thread.
Posted
by thgh.
Last updated
.
Post not yet marked as solved
0 Replies
17 Views
Hello, I'm just starting with Xcode and I was trying to learn with apples examples. I wanted to edit one off the example Apps to my liking but don't really know how to do so. In the App, the national parks are divided in three categories: Lakes, Mountains and Rivers. (see image) As of now to see all listed parks you would go to the list icon and see a list of all the parks. (see image) What I want to do is the following: When you click on the list Icon, you won't see all the listed parks, but a short list of the previously mentioned categories and by clicking on the list you'll see the parks in the chosen category. This is the program I'm using. https://developer.apple.com/tutorials/swiftui/interfacing-with-uikit I hope somebody can help me with this project. If you got any follow-up questions please let me know.
Posted
by gonzalni.
Last updated
.
Post marked as solved
2 Replies
47 Views
Howdy, Is it possible to inset the left and right edges of the cells contained within a UITableView? I initially thought that contentInsets would do the trick, but I can't to get this to work. More specifically, it seems that adjusting the contentInsets only affects the scrollable area rather than the area actually occupied by the cells. Are the cells not a part of the content? The only other way I can think of doing this is by embedding the UITableView inside another UIScrollView, which feels like overkill. Is there a better way? Note that I do not want to adjust the bounds of the UITableView because I want the area occupied by the insets to remain scrollable. Thanks, smkuehnhold
Posted Last updated
.
Post not yet marked as solved
1 Replies
30 Views
UIMenu documentation uses UIKeyCommand to make a UIMenu. I made one for a UIBarButtonItem. UIKeyCommand documentation says Key command sequences are generated only for devices with an attached hardware keyboard. But it's working fine on my iPhone SE. I don't understand this. Can some explain please? Thanks.
Posted Last updated
.
Post not yet marked as solved
2 Replies
103 Views
Hello, I'm using UITableViews with cells containing either a UICollectionView or UITableView in them. The cell's height is dependent on the content of the table/collectionView inside it. Think of it like the sections in the Settings app. This all has been working fine for 2 years now (on iPhone/iPad/Mac running Mac Catalyst), but this week's macOS 12.5 release has caused every cell like this to have some items seemingly missing. However, clicking on a missing item will still have the correct action work, or moving the mouse around/above the missing cells, they will cause the correct content to appear. Here's a code snippet of a tableView cell with a UITableView in it: class SettingsCell: UITableViewCell, UITableViewDelegate, UITableViewDataSource { @IBOutlet weak var contentTable: UITableView! //Height constant of tableView in cell @IBOutlet weak var contentTableHeightConstraint: NSLayoutConstraint! private var _type: SettingType = .unknown override func awakeFromNib() { super.awakeFromNib() contentTable.delegate = self contentTable.dataSource = self contentTable.isScrollEnabled = false contentTable.register(UINib(nibName: "SettingsRowCell", bundle: nil), forCellReuseIdentifier: "SettingsRowCell") contentTable.estimatedRowHeight = 45.0 contentTable.rowHeight = UITableView.automaticDimension layoutIfNeeded() contentTableHeightConstraint.constant = contentTable.contentSize.height } //This is called in the cellforRowAt method in the parent table where it chooses which type of settings section to show func updateWithType(type: SettingType) { _type = type contentTable.reloadData() layoutIfNeeded() contentTableHeightConstraint.constant = contentTable.contentSize.height } func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { if type == .general { return generalArray.count } else if type == .notifications { return notifArray.count } return 0 } func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { return 45 } } The issue seems to steam from a tableView or collectionView being inside a tableViewCell because happens to all my cells like this. I've been digging through the code for days, and nothing is out of the ordinary. I never hide any of the cell's content in any scenario, so this isn't the normal reusable cell issue where the content needs to be set back to being visible. Does anyone know of the fix this or has any pointers? Also, these cells work as normal on iPhone/iPad. I've been trying to figure this out for a long time, and any help would be greatly appreciated!
Posted
by helper132.
Last updated
.
Post not yet marked as solved
1 Replies
101 Views
Facing issue of NSUserDefaults data got cleared on update new version from app store. so all data of user got cleared and user have to login again. I was having app in store with version 1.1.3 and then we have uploaded new version to store with version 1.1.4 but when user download app from store their data was cleared from UserDefaults.so this is big issue in update. need to help. is that apple updated any process on update. Question How Apple change version build in device when we update app from app store. is it uninstall old build and install new build ? Or it is install new version on old version ? Should UserDefaults.standard will delete on update ? Updating Provisioning profile from manual to automatically cause issue on UserDefaults.standard Like UserDefaults got cleared and uuid will change ? Do we have anythings that we can identify specific user as uniq user ? What is better solution to store login data into SQLite store or in UserDefaults as model ? Will appreciate for your help. this is very big issue and login again on update will make app user more effect
Posted Last updated
.
Post not yet marked as solved
11 Replies
3.5k Views
i have a list like this: id: 1, image: image1, title: title1, badge: 0 id: 2, image: image2, title: title2, badge: 0 id: 3, image: image3, title: title3, badge: 0 ... is my understanding correct that in order to do a smooth "expected" animation when I want to change both the badge of the item and its order i have to manually split this "big" update into two smaller updates (first change then move, or vice versa)? this is somewhat surprising, i would expect a diffable implementation to have a notion of "identity" (in the example above it's "id") and calculate the differences based on that identity plus ite equivalence check rather than just based on the hash/equality check for the whole item.
Posted Last updated
.
Post marked as solved
4 Replies
535 Views
Hi guys Has anybody hit any issues with the Navigation bar and tab bars being in the safe area. With ios16 the navigation bar appears onto of the status bar (in the safe area), the tab bar is also in the safe area. However, putting the device into landscape and then portrait brings it back closer (although the buttons no longer have an indentation). In the screenshot on the left is how the app is first displayed and on the right is how it changes after rotation. This is working fine in ios15 I know Apple having been making changes in this area, but the app is set to ios15 as the minimum deployment and I'm not using any of the new features, so I wasn't expecting this issue. Changing the navigation bar frame seems to have no effect Anybody any clues?
Posted
by rowets2.
Last updated
.
Post marked as solved
3 Replies
635 Views
Hi, I am faced with a strange problem with a Catalyst app that uses MapKit. If the map is visible and I resize the window (causing the map the resize), sometime the app crashes with some Metal related error. Is this a know issue between MapKit and Catalyst? There is something I can do in order to prevent this crash? Below you can find the error message and a screenshot of the thread that caused the crash. Thank you -[MTLDebugDevice notifyExternalReferencesNonZeroOnDealloc:]:2951: failed assertion `The following Metal object is being destroyed while still required to be alive by the command buffer 0x7f96de27f600 (label: <no label set>): <MTLToolsObject: 0x7f96dde552e0> -> <BronzeMtlTexture: 0x7f96dc04c230> label = <none> textureType = MTLTextureType2D pixelFormat = MTLPixelFormatBGRA8Unorm_sRGB width = 2372 height = 1668 depth = 1 arrayLength = 1 mipmapLevelCount = 1 sampleCount = 1 cpuCacheMode = MTLCPUCacheModeDefaultCache storageMode = MTLStorageModeManaged hazardTrackingMode = MTLHazardTrackingModeTracked resourceOptions = MTLResourceCPUCacheModeDefaultCache MTLResourceStorageModeManaged MTLResourceHazardTrackingModeTracked usage = MTLTextureUsageShaderRead MTLTextureUsageRenderTarget shareable = 0 framebufferOnly = 0 purgeableState = MTLPurgeableStateNonVolatile swizzle = [MTLTextureSwizzleRed, MTLTextureSwizzleGreen, MTLTextureSwizzleBlue, MTLTextureSwizzleAlpha] isCompressed = 0 parentTexture = <null> parentRelativeLevel = 0 parentRelativeSlice = 0 buffer = <null> bufferOffset = 0 bufferBytesPerRow = 0 iosurface = 0x0 iosurfacePlane = 0 allowGPUOptimizedContents = YES'
Posted
by DaleOne.
Last updated
.
Post not yet marked as solved
1 Replies
61 Views
I recently updated to Macos Ventura beta 4 along with Xcode 14 beta 4, now I can't work because Xcode crashes anytime I try to open the library panel either by the "+" icon or the keyboard shortcut. I have tried deleting Xcode caches and I also reinstalled Xcode but the issue persist
Posted Last updated
.
Post not yet marked as solved
1 Replies
59 Views
I'm using an instance of a UIPrintPageRenderer subclass to print many records, each of which is included by adding a UIViewPrintFormatter generated by a myTextView.viewPrintFormatter(). Some of the records occupy much less than a page, so I'd like to print the next record on the remaining page space after printing the previous one (only if there is enough space for the entire of the next record on that same page). In order to do this, I'm attempting to calculate how much space is remaining, and where on the page it starts as follows: class MyCustomPrintPageRenderer: UIPrintPageRenderer { func inWhichPrintFormattersAreAdded() { var startPage: Int = 0 for rec in records { let myUIViewPrintFormatter = myTextView.viewPrintFormatter() if enoughSpaceRemainingOnPage() { myUIViewPrintFormatter.perPageContentInsets.top = prevRecBottom } else { startPage += 1 } addPrintFormatter(myUIViewPrintFormatter, startingAtPageAt: startPage) ... ... ... let lastPage = startPage + myUIViewPrintFormatter.pageCount - 1 let lastRect = myUIViewPrintFormatter.rectForPage(at: lastPage) print(lastRect) print(printableRect) ... ... ... startPage = lastPage prevRecBottom = lastRect.origin.y + lastRect.size.height } } } However, the two print() statements always result in exactly the same output - the entire page printable rect. I can't just use the print formatter's total size, as some of them are large enough to occupy multiple pages. I just need to figure out how much space is left on the last page, to see if the next print formatter might fit there. How can I find the used and/or remaining space left on the last page after a UIViewPrintFormatter has been added to a UIPrintPageRenderer ?
Posted Last updated
.
Post not yet marked as solved
1 Replies
39 Views
Hi Team, In my application I have customised a UIDatePicker (set custom color for selected date) that was working correctly in iOS 15.5 and lower versions but when I run the app in iOS 16 beta, I don't see my settings for current date is working. Check the following code currently Im using, datePicker.datePickerMode = .date datePicker.calendar = .current datePicker.timeZone = TimeZone(secondsFromGMT: 0) if #available(iOS 13.4, *) { datePicker.preferredDatePickerStyle = .wheels } datePicker.setValue(UIColor.systemPink, forKeyPath: "textColor") datePicker.setValue(false, forKey: "highlightsToday") Please find the screenshot for more information and kindly share your feedback if any. Thanks in advance.
Posted Last updated
.
Post marked as solved
7 Replies
2.8k Views
I have looked a bit in the iOS 9.3 API Diffs, as well as searching the developer website and these forums, and did not see any references.Is there an API determine if Night Shift is active?
Posted Last updated
.
Post not yet marked as solved
0 Replies
71 Views
We have a handful of users with the iOS16 beta that are reporting app crash on launch. We're seeing this new crash which seemingly only impacts iOS 16 users, but the crash report doesn't seem to indicate a crash point in our app (only OS/system level objects). In the crash log, the main thread appears to be stuck in a loop with trait collections possibly leading to resource exhaustion/stack overflow, but I can't see where the stack begins within our app at all, everything in the log seems OS level. UPDATE: Started on 27 July 2022, which is the same release date as iOS 16 Beta 4 (20A5328h) - confirmed all crash reports are for this release of iOS 16 (20A5328h). Bug report logged https://feedbackassistant.apple.com/feedback/11079459 . Screenshot from Organizer and crash report below: 2022-08-05_11-06-29 - ios16 Crash Report.txt
Posted Last updated
.
Post not yet marked as solved
0 Replies
22 Views
I'm using an instance of a UIPrintPageRenderer subclass to print many records, each of which is included by adding a UIViewPrintFormatter generated by a myTextView.viewPrintFormatter(). Some of the records occupy much less than a page, so I'd like to print the next record on the remaining page space after printing the previous one (only if there is enough space for the entire of the next record on that same page). In order to do this, I'm attempting to calculate how much space is remaining, and where on the page it starts as follows: class MyCustomPrintPageRenderer: UIPrintPageRenderer { func inWhichPrintFormattersAreAdded() { var startPage: Int = 0 for rec in records { let myUIViewPrintFormatter = myTextView.viewPrintFormatter() if enoughSpaceRemainingOnPage() { myUIViewPrintFormatter.perPageContentInsets.top = prevRecBottom } else { startPage += 1 } addPrintFormatter(myUIViewPrintFormatter, startingAtPageAt: startPage) ... ... ... let lastPage = startPage + myUIViewPrintFormatter.pageCount - 1 let lastRect = myUIViewPrintFormatter.rectForPage(at: lastPage) print(lastRect) print(printableRect) ... ... ... startPage = lastPage prevRecBottom = lastRect.origin.y + lastRect.size.height } } } However, the two print() statements always result in exactly the same output - the entire page printable rect. I can't just use the print formatter's total size, as some of them are large enough to occupy multiple pages. I just need to figure out how much space is left on the last page, to see if the next print formatter might fit there. How can I find the used and/or remaining space left on the last page after a UIViewPrintFormatter has been added to a UIPrintPageRenderer ?
Posted Last updated
.
Post not yet marked as solved
1 Replies
72 Views
Hi, I just discovered a weird bug with UITextView on iOS 16 beta 4. For some reason now, when the scrolling is disabled, the intrinsic content size of the text view is considering the line spacing even when the textview is empty. For example, in the below code we are setting a big lineSpacing of 50 to the text view typingAttributes attribute. class ViewController: UIViewController { @IBOutlet weak var textView: UITextView! { didSet { //Let's set the textView typingAttributes with a lineSpacing of 50. var attributes = [NSAttributedString.Key: Any]() let paragraphStyle: NSMutableParagraphStyle = NSMutableParagraphStyle() paragraphStyle.lineSpacing = 50 attributes[NSAttributedString.Key.paragraphStyle] = paragraphStyle attributes[NSAttributedString.Key.font] = UIFont.preferredFont(forTextStyle: .body) textView.typingAttributes = attributes } } } On previous iOS versions, everyting it's ok and the line spacing is added only when there are more than one line (see below image). However, on iOS 16 beta 4, the line spacing is added also when the content is empty (see below image on the left). A soon as we type something the height collapse to the correct height (see below image in the center). Is this a new expected behavior or a bug? If it is a bug, someone has found a temporary fix for that? Thank you
Posted
by DaleOne.
Last updated
.
Post not yet marked as solved
0 Replies
37 Views
I have set up a pulldown button in the navigation bar which automatically got embedded in a UiBarButtonItem. Menus have been set up from interface builder itself. since UIBarbuttonItem doesn't have a showMenuAsPrimaryAction property. Now when I run the code on device or simulator, I don't see the menu pop up. Neither on tap nor or long press. I don't know what I'm doing wrong. Please see the screenshot of storyboard. The button has no title just an Image which is not seen when double clicked on it (to reveal the menu) in interface builder. So don't be confused with the empty white space in place of the button.
Posted Last updated
.
Post not yet marked as solved
1 Replies
71 Views
Hi ! In discovery for why screen gestures were not being deferred when using correct function in an Objective-C/C++ UIViewController discovered this issue Does not affect Swift Tools Tested: Xcode 13/14 Beta iOS Target 12 + Deferring gestures when using Objective-C UIViewController does not work using the normal bitwise op or the default Apple created bitwise op pipes ( | ) UIRectEdgeAll - Does not work: - (UIRectEdge)preferredScreenEdgesDeferringSystemGestures {     return UIRectEdgeAll; } UIRectEdge - using | - Does not work: - (UIRectEdge)preferredScreenEdgesDeferringSystemGestures {     UIRectEdge edges = UIRectEdgeNone; edges | UIRectEdgeTop;       edges | UIRectEdgeBottom;       edges | UIRectEdgeLeft;       edges | UIRectEdgeRight;     return edges; } Working solution for Objective-C use in UIViewController to use |= instead of | - (UIRectEdge)preferredScreenEdgesDeferringSystemGestures {     UIRectEdge edges = UIRectEdgeNone; edges |= UIRectEdgeTop;       edges |= UIRectEdgeBottom;       edges |= UIRectEdgeLeft;       edges |= UIRectEdgeRight;     return edges; } Issue originates in Objective-C code here for UIRectEdgeAll : UIKit/UIGeometry.h typedef NS_OPTIONS(NSUInteger, UIRectEdge) {     UIRectEdgeNone   = 0,     UIRectEdgeTop    = 1 << 0,     UIRectEdgeLeft   = 1 << 1,     UIRectEdgeBottom = 1 << 2,     UIRectEdgeRight  = 1 << 3,     UIRectEdgeAll    = UIRectEdgeTop | UIRectEdgeLeft | UIRectEdgeBottom | UIRectEdgeRight } API_AVAILABLE(ios(7.0)); Pipes used does not work: (use of |) UIRectEdgeAll    = UIRectEdgeTop | UIRectEdgeLeft | UIRectEdgeBottom | UIRectEdgeRight Solution (for Apple Engineers) : Change bitwise pipe to instead of | to be |= (or equal to, += basically) in UIKit/UIGeometry.h
Posted Last updated
.