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

UIKit Documentation

Posts under UIKit tag

1,003 results found
Sort by:
Post marked as solved
8.6k Views

barTintColor not working in iOS 15

Hi, When I run the following code in application(_ :didFinishLaunchingWithOptions) in iOS 15, the bar color turns transparent (thus, showing the black background underneath), while the same code works fine in iOS 14.5: UINavigationBar.appearance().isTranslucent = false UINavigationBar.appearance().barTintColor = .red Here's the screenshots of Simulators running iOS 14.5 and iOS 15: I'm using Xcode 13 on macOS Big Sur 11.4. Thanks!
Asked Last updated
.
Post not yet marked as solved
18 Views

Xcode 13 -> UITest tap the wrong uicell

Hello. After upgrading to Xcode 13, multiple of my uitests involving uicell in collection view failed because the test tap the wrong cell (it tap the cell next to the good one). I checked the values with the accessibility investigator and the values are good. No problem when i rollback to xcode 12.
Asked
by Kew.
Last updated
.
Post not yet marked as solved
41 Views

Is it possible somehow in iOS to prevent screen capture?

Is there's way to prevent taking screenshots entirely while using my app? I need to prevent screen capture by users of my app, for security reasons. The contents I display are confidential and should not be copied onto the device.
Asked
by DBox.
Last updated
.
Post not yet marked as solved
23 Views

"unable to dequeue a cell with identifier" only on iPadOS 15.0

I have a UITableView based up. It is running fine on all iOS versions including 15.0. It is also running fine on all iPadOS versions up to 14.x. But only on iPadOS 15.0 it crashes with the following error message: *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'unable to dequeue a cell with identifier TextCell - must register a nib or a class for the identifier or connect a prototype cell in a storyboard' Is this a know issue? How can I debug it to figure out where the problem lies? Note that I actually do register the NIB as follows in viewDidLoad: static NSString *reuseIdentifierTextCell = @"TextCell"; [self.tableView registerNib:[UINib nibWithNibName:@"ChatTextCellCondensed" bundle:nil] forCellReuseIdentifier:reuseIdentifierTextCell]; It is crashing at this line in cellForRowAtIndexPath: cell = [tableView dequeueReusableCellWithIdentifier:reuseIdentifierTextCell forIndexPath:indexPath]; Thanks!
Asked
by l00.
Last updated
.
Post not yet marked as solved
28 Views

Migrating from UIScrollView to UICollectionView

I have prototyped multilayer timeline with custom cells, where: a. Each cell has possibly different size. Some cell sizes can be more than visible rect of ScrollView, b. The gap between cells may be different (even though it appears same in the picture below), except the first(base) layer where the cell gap is fixed to 2 points, c. Each cell can be selected and trimmed/expanded from each end using UIPanGestureRecognizer. Trimming/Expansion have custom rules. For the base layer, cell simply pushes other cells as it expands or contracts. For other layers however, the trimming or expansion have to respect boundaries of neighbouring cells. d. Timeline can be zoomed horizontally which has the effect of scaling cells e. Cells can be dragged and dropped to other rows subject to custom rules. I have implemented all this using UIScrollView. By default all cells are initialized and added to UIScrollView, whether they are visible or not. But now I am hitting limits as I draw more content on each cell. Which means I need to reuse cells and draw only visible content. I discussed this with Apple Engineers in WWDC labs and one of the engineer suggested I use UICollectionView with custom layout where I can get lot of functionality for free (such as cell reuse, drag and drop). He suggested me looking into WWDC 2018 video (session 225) on UICollectionView. But as I look at custom layout of UICollectionView, it's not clear to me: Q1. How to manually trim/expand select cells in UICollectionView with custom layout using UIPanGesture? In case of UIScrollView, I just have a UIPanGestureRecognizer on cell and do the trimming and expansion of it's frame (respecting given boundary conditions). Q2. How to scale all the cells with a given zoom factor? With UIScrollView, I simply scale the frames of each cell and then calculate contentOffset to reposition UIScrollView around the point of zoom. Even with UICollectionView with just one cell which has width say 10x of UICollectionView frame width, I will need further optimization to draw content on only visible portion rather than the whole cell. How is that possible with UICollectionViewCell to draw only part of the cell that's visible on screen?
Asked Last updated
.
Post not yet marked as solved
23 Views

.usesFontLeading gives a different height

Hey, When I use boundingRect with String, and supply .usesFontLeading as one of the options, I get an inaccurate height for some reason. Why is that?
Asked Last updated
.
Post not yet marked as solved
40 Views

.usesFontLeading gives a different height when used with boundingRect

I'm using boundingRect to calculate the height of a String, I'm using Ubuntu as my font, and when I supply .usesFontLeading as one of the options alongside .usesLineFragmentOrigin the height is completely different to what I expect. Here is the code I'm using for reference: func height(withConstrainedWidth width: CGFloat, font: UIFont, maxLines: CGFloat = 0) -> CGFloat {         let constraintRect = CGSize(width: width, height: .greatestFiniteMagnitude)         let boundingBox = self.boundingRect(with: constraintRect, options: [.usesFontLeading, .usesLineFragmentOrigin], attributes: [             NSAttributedString.Key.font: font         ], context: nil)         var size = boundingBox.size         if maxLines > 0 {             size.height = min(size.height, CGFloat(maxLines) * font.lineHeight)         }         return ceil(size.height)     } Firstly, what does .usesFontLeading even do, and why is it that the result I'm getting an unexpected result. Note: self is String because I've extended the String class.
Asked Last updated
.
Post marked as solved
32 Views

intrinsicContentSize ignoring the width, leading, and trailing anchors

I've constrained a UILabel to leading, and trailing anchors, the intrinsicContentSize exceeds the anchors I've specified. Just to be sure, I added a widthAnchor as well, still no improvement. Then I added these properties: self.preferredMaxLayoutWidth = 356.25 // didn't hard code self.invalidateIntrinsicContentSize() Still the intrinsicContentSize is equal to 356.5, which is something I don't expect from my UILabel, is there anyway to fix this issue?
Asked Last updated
.
Post not yet marked as solved
68 Views

iPadOS 15, cannot replace/destroy foreground scene, and activate an existing background scene.

I have a document based app, and if the user tries to open a document in the active/foreground scene, and that document is already open in another existing scene, I would like to activate that existing scene, and destroy the current foreground one. I do it like that: UIApplication.shared.requestSceneSessionActivation(existingSession, userActivity: activity, options: nil) UIApplication.shared.requestSceneSessionDestruction(foregroundSession, options: nil) When I run this code, the foreground scene is destroyed, but the activated one is not brought to foreground, it simply takes me to home screen. On iOS14, it kinda works, the existing one is brought to foreground and splits the screen with the current foreground one for a split second, then the current one is destroyed, and the existing scene now takes all the screen. The intermediate split state is not visually nice but it does it's job. How can I achieve the same behaviour on iOS15?
Asked Last updated
.
Post not yet marked as solved
58 Views

UICollectionViewController + UITextField autoscroll behavior

Hi all! I have a UICollectionViewController with cells that contain UITextField items. On iOS 14, switching firstResponder status between each text field programmatically caused the UICollectionView to auto-scroll the items into view. On iOS 15 this behavior still occurs, but the animation is jittery. The scrollview jumps up and down rapidly while the animation occurs. As a sanity check, I have no other code executing while this animation occurs. The contentInsets and contentOffset are only being affected by the firstResponder animation. Any ideas why this might be happening?
Asked
by mbciarlo.
Last updated
.
Post not yet marked as solved
3.6k Views

Disable dynamic type

Is it possible to completely disable dynamic type for an app? If not, is it possible to disable the dynamic type feature for UITableViewCell classes?
Asked
by Neoos.
Last updated
.
Post not yet marked as solved
322 Views

canOpenURL returned an incorrect result in iOS 15 run in Xcode13

[[UIApplication sharedApplication] canOpenURL:url] don‘t work run in iOS 15 beta and Xcode13. But it works well in iOS 15 beta and Xcode12. Delete some schemes from LSApplicationQueriesSchemes. Some schemes can work and others still can't work. It has some randomness. I don't know whether it is a system bug or a new rule.
Asked Last updated
.
Post marked as solved
80 Views

BackgroudColor of UINavigationBarAppearance() does not work in iOS15.

The background color of the navigation bar of "Photo Library" displayed by WKWebView in iOS15 does not work with the backgroudColor of UINavigationBarAppearance(). It works on iOS14. AppDelegate.swift if #available(iOS 15, *) { let appearance = UINavigationBarAppearance() appearance.backgroundColor = .red UINavigationBar.appearance().standardAppearance = appearance UINavigationBar.appearance().scrollEdgeAppearance = appearance UINavigationBar.appearance().compactAppearance = appearance } else { UINavigationBar.appearance().barTintColor = .red } ViewController.swift let webConfiguration = WKWebViewConfiguration() webView = WKWebView(frame: .zero, configuration: webConfiguration) webView.uiDelegate = self webView.navigationDelegate = self view = webView guard let path: String = Bundle.main.path(forResource: "index", ofType: "html") else { fatalError() } let myURL = URL(fileURLWithPath: path, isDirectory: false) self.webView.loadFileURL(myURL, allowingReadAccessTo: myURL) index.html <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Sample</title> </head> <body> <input type="file" name="example" accept="image/jpeg,image/png"> </body> </html> Version/Build iOS 15 RC Xcode 13 RC
Asked
by shima_pon.
Last updated
.