ViewControllers for the 8th and higher tabs are not displayed in the elevated Tab Bar. However, I am able to select these tabs both in the Tab Bar and the side bar.
func setTabs(){
let colors = [UIColor.red,.systemGray6,.green,.systemMint,.cyan,.yellow,.blue,.magenta]
var tabs = [UITab]()
let range = 0...10
for index in range {
if #available(iOS 18.0, *) {
let tab = UITab(title: "Tab_\(index)", image: UIImage(systemName: "globe"), identifier: "tab__\(index)", viewControllerProvider: {tab in
let vc = UIViewController()
vc.view.backgroundColor = colors[index%colors.count]
return vc
})
tabs.append(tab)
}
}
tabbarController.setTabs(tabs, animated: true)
}
UIKit
RSS for tagConstruct and manage graphical, event-driven user interfaces for iOS or tvOS apps using UIKit.
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
I have some key commands registered in Responder chain on IOS application that reacts to F1-F12 keys. I have bluetooth keyboard connected to ipad that has some default functions assigned to most of F keys and because of that my application doesn't react when i click F key and fires the default behaviour.
For example i have callback registered on F1 key that has default function of dimming the screen. When i click F1 key the screen is dimmed and the callback is not fired.
When i click on F5 which does not have any default function the callback is called properly.
How can i disable this default behaviour or somehow make my application react to FKeys?
Keyboard model: A1644
Ipad 6
Topic:
UI Frameworks
SubTopic:
UIKit
In iOS18, Not able to use the UITabBarControllerDelegate.tabBarController(:didSelectTab:previousTab:) function. Since it have duplicate parameter name for didselectTab and previousTab , we're getting Invalid redeclaration of 'tab' error.
I am experimenting with drag-and-drop on iPadOS.
If I drag a JPEG image from a webpage in Safari to my app, I get items of types public.jpeg and public.url.
Typically, the URL is the URL of the image.
If, however, the image is itself a link, then the URL seems to be the target of the link.
Is there some way that I can always get the URL of the image itself? Is there some way that I can determine whether the URL I have received is the URL of the image or of a link?
I have a tableview and I want to use a custom section header.
Instead of writing out all the code to create the section header, I added the view to my XIB file and connected it to an outlet in my view controller. I hid the view behind another view so it isn't visible and doesn't take up any room in the layout of the screen.
In my view controller, I removed the view from the layout (removeFromSuperview) and then I returned it from my viewForHeaderInSection function. I also implemented heightForHeaderInSection to make sure I get the right height.
When I run my app, what shows up is a blank space in the table where I'm expecting the header view to be. The space is the right height, but there is nothing in it. I do not understand why.
Topic:
UI Frameworks
SubTopic:
UIKit
I'm making a UIKit app with no storyboard.
This is my scene delegate:
import UIKit
class SceneDelegate: UIResponder, UIWindowSceneDelegate {
var window: UIWindow?
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
guard let windowScene = (scene as? UIWindowScene) else { return }
let window = UIWindow(windowScene: windowScene)
window.makeKeyAndVisible()
window.rootViewController = UINavigationController(rootViewController: ViewController())
self.window = window
}
}
I've noticed that if I subclass ViewController to UICollectionViewController, the app crashes with message "Thread 1: "UICollectionView must be initialized with a non-nil layout parameter"":
import UIKit
class ViewController: UICollectionViewController {
}
It looks like I necessarily need to override the initializer:
import UIKit
class ViewController: UICollectionViewController {
init() {
super.init(collectionViewLayout: .init())
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
I would indeed like to pass the final collection view layout in super.init(collectionViewLayout:), but defining the trailing actions before that isn't possible since self hasn't been initialized yet.
So this is what I'm stuck with:
import UIKit
class ViewController: UICollectionViewController {
init() {
super.init(collectionViewLayout: .init())
var configuration = UICollectionLayoutListConfiguration(appearance: .insetGrouped)
var layout = UICollectionViewCompositionalLayout.list(using: configuration)
configuration.trailingSwipeActionsConfigurationProvider = { [weak self] indexPath -> UISwipeActionsConfiguration? in
// access a property of self
return .init(actions: [.init(style: .destructive, title: "Hello", handler: { _,_,_ in print("Handled") })])
}
layout = UICollectionViewCompositionalLayout.list(using: configuration)
collectionView.collectionViewLayout = layout
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
Is this all valid?
Topic:
UI Frameworks
SubTopic:
UIKit
Hi,
We had published a hybrid app build on ionic capacitor and we could see the crash report from iOS version greater than 17.5.
From the crash report it is difficult to find the root cause of the issue.
Could you please check the crash logs and help on this.
Attached the crash logs file here
crashlogs.txt
In iOS 18 on iPad, the elevated tab bar order is persisted by the system. After reordering the tabs, how can I retrieve the current order of the tabs? and how to override the order programatically.
Why is the testFieldDidChangeSelection function called three times when the return key is pressed?
Here is what I did
enter text in TextField
press the Return key
The result is that the textFieldDidChangeSelection function is called three times.
I would like to know why.
As a supplement, I asked ChatGPT and the results are below.
At the moment the Return key is pressed: The cursor is updated at the position of the last character entered in the text field.
Insertion of a newline: When the Return key is pressed, a new line is added, and the cursor moves to the beginning of the new line.
Finalization of the edit: Finally, the content of the text field is confirmed, and the position of the cursor is finalized.
Also, is the above answer true?
In iOS 18, with the elevated tab bar, the title of the primary view controller in a UISplitViewController automatically hides when the Split View is expanded. However, the title label is still present in the view hierarchy. How to resolve this issue?
Xcode15 has been running normally, upgrade to Xcode16 beta4, running crash, crash code is as follows:
What am I supposed to do to fix this.
Can't my property be named maskView in Xcode16 beta4?
in iOS 15.0 Devices when implementing UItableView Drag/Drop using delegate, I am facing an issue.
UITableViewDropDelegate Methods are not called.
func tableView(_ tableView: UITableView, dropSessionDidEnter session: UIDropSession) {
//This is called
}
func tableView(_ tableView: UITableView, canHandle session: UIDropSession) -> Bool {
//This gets called
return true
}
func tableView(
_ tableView: UITableView,
dropSessionDidUpdate session: UIDropSession,
withDestinationIndexPath destinationIndexPath: IndexPath?
) -> UITableViewDropProposal {
//Does not gets called
}
/**
This delegate method is the only opportunity for accessing and loading
the data representations offered in the drag item. The drop coordinator
supports accessing the dropped items, updating the table view, and specifying
optional animations.
*/
func tableView(_ tableView: UITableView, performDropWith coordinator: UITableViewDropCoordinator) {
//Does not gets called
}
The issue only occurs in iOS 15.0 devices. OS version>15.0 it works fine.
Delegate method registered using
tableView.dragInteractionEnabled = true
tableView.dragDelegate = self
tableView.dropDelegate = self
Is there any solution to this?
I want to achieve Fold animation when the user scrolls UICollectionView. I have UICollectionView with full-screen size cell and vertically scrolling with paging enabled. For that I've created sub-class of UICollectionViewFlowLayout which is as described below.
class FoldingFlowLayout: UICollectionViewFlowLayout {
private let logger = Logger(subsystem: bundleIdentifier, category: "FlowLayout")
override func prepare() {
super.prepare()
scrollDirection = .vertical
minimumLineSpacing = 0
minimumInteritemSpacing = 0
}
override func layoutAttributesForElements(in rect: CGRect) -> [UICollectionViewLayoutAttributes]? {
let attributes = super.layoutAttributesForElements(in: rect)
attributes?.forEach { attribute in
transformLayoutAttributes(attribute)
}
return attributes
}
override func shouldInvalidateLayout(forBoundsChange newBounds: CGRect) -> Bool {
return true
}
private func transformLayoutAttributes(_ attributes: UICollectionViewLayoutAttributes) {
guard let collectionView = collectionView else { return }
let contentOffsetY = collectionView.contentOffset.y
let cellOffsetY = attributes.frame.origin.y - contentOffsetY
let cellHeight = attributes.frame.height
var transform = CATransform3DIdentity
transform.m34 = -1.0 / 500.0 // Apply perspective
if cellOffsetY < cellHeight && cellOffsetY > -cellHeight {
let angle = (cellOffsetY / cellHeight) * .pi / 2
transform = CATransform3DRotate(transform, angle, -1, 0, 0)
attributes.transform3D = transform
attributes.alpha = 1.0 - (abs(cellOffsetY) / cellHeight)
} else {
attributes.transform3D = CATransform3DIdentity
attributes.alpha = 1.0
}
}
}
But this is not working as I expected. I want to create replica of this kind of animation.
What am I missing here?
In our application we have one banner via UIStackview which has one UIBotton & UILabel in horizontal stackview.
In UI is working fine in all the iOS Version & devices but it is creating issue for iOS 14.2 iPhone 6s.
We have verified the same in iOS 15.3.1 iPhone 6s, its is working fine.
We are attaching 2 screenshot:
Our Storybaord specific ui component.
The distorted UI of iOS 14.2 iPhone 6s.
Kindly update us on priority as end customer is facing issue.
We maintain a device driver for macOS. This consists of a bunch of components including a Launch Agent, a (Cocoa/AppKit) status bar item app, and a "main" windowed UI app. These all communicate with each other via XPC using the "low level" XPC APIs (libxpc). The launch agent registers a named Mach XPC service, and the two apps connect to it when they launch.
Last year, we had an overhaul of the main UI app as we wanted to add a bunch of features. In the process we decided to switch it from Cocoa/AppKit to Mac Catalyst/UIKit as we were also contemplating porting the driver to iPadOS in future; plus, UIKit is a little simpler and I'm not a great UI programmer, so any simplification is welcome.
This has worked OK so far, but in our attempt to upgrade our build toolchain from Xcode 15.2 to Xcode 15.4 we found that the Catalyst app would no longer build. Apparently the xpc_connection_create_mach_service() and xpc_connection_set_peer_code_signing_requirement() functions are no longer available as of the Mac Catalyst SDK included with Xcode 15.3. This makes it impossible for the app to connect to the launch agent's XPC service.
A few things to note:
These functions were never deprecated, so we did not have their impending removal on our radar.
It seems they actually used to be available in the iOS SDK and were removed from that, so Mac Catalyst is effectively collateral damage. I don't think these would ever have been usable in apps on the iOS App Store, so perhaps they were removed from the iOS SDK ahead of support for notarised iOS app distribution.
So it looks like they might have been removed from Mac Catalyst SDK by accident? I therefore filed a bug about this - FB13929309 - about 6 weeks ago. Reinstating the functions for Mac Catalyst would seem like a very straightforward fix, but I've not had a hint of feedback on the report.
I guess my forum question comes down to this: Is Mac Catalyst considered a platform for building macOS apps in its own right? Or are we "holding it wrong" and should we only treat it as a way of tweaking Mac ports of iOS/iPad-first apps? Should we expect APIs to disappear from the Mac Catalyst SDK with zero notice?
We can still build with Xcode 15.2 for the moment, and the app built this way runs fine up to and including the macOS 15 beta. But thanks to the limited forward and backward compatibility schedule for Xcode we can't stay on old Xcode for long We're also planning to make some feature changes to the app in the near future, and I don't want to be investing in an app built on a platform with no future. I'd rather port the app back to Cocoa/AppKit before adding features if that's the case.
iOS 18 introduced the elevated tab bar for iPad devices. However, the tint color for UITabBar items is not changing. Adjusting the barTintColor and tintColor properties of the tab bar items does not seem to have any effect.
On iOS17, when the device is on Dark mode, the background of the Edit Mode in QLPreviewController has white color, instead of dark color. (like in the iOS18 betas)
We support both iOS17 and iOS18 and we want our users to have a consistent experience, so we think this should be aligned in iOS17, as it's currently working in iOS18 betas.
Steps:
Set the device to Dark Mode.
Present a QLPreviewController and preview an image.
Enable Markup/Edit mode.
Observe the image background
Actual Result: The background is in white color.
Expected Result: The background is in dark color. (Just like in iOS18 betas)
Xcode 16b3, All iPhones.
I'm getting a crash on iOS 14.4.1 and other older versions when entering text into a UITextBox in my game. I tried disabling auto correct on the field and it seemed to make the issue occur less often, but it is not solving 100% of the cases. Does anyone know how to prevent this exception and turn off auto complete on the text field entirely? None of the call stack is actually my code other than main.
Update: I am already setting self.textInput.autocorrectionType = UITextAutocorrectionTypeNo;
0 CoreFoundation +0x125868 ___exceptionPreprocess
1 libobjc.A.dylib +0x6c4c _objc_exception_throw
2 CoreFoundation +0x1e4a0 +[NSException raise:format:]
3 QuartzCore +0x16adb0 CA::Layer::set_position(CA::Vec2&lt;double&gt; const&amp;, bool)
4 QuartzCore +0x16ace0 -[CALayer setPosition:]
5 QuartzCore +0x16a7b8 -[CALayer setFrame:]
6 UIKitCore +0x10f8184 -[UIView(Geometry) setFrame:]
7 UIKitCore +0x9b7038 -[UIKeyboardImpl updateAutocorrectPrompt:correctionRects:]
8 UIKitCore +0x9b6a54 -[UIKeyboardImpl updateAutocorrectPrompt:executionContext:]
9 UIKitCore +0x9d5274 ___56-[UIKeyboardScheduledTask handleDeferredTimerFiredEvent]_block_invoke
10 UIKitCore +0x9d57d8 -[UIKeyboardTaskEntry execute:]
11 UIKitCore +0x9d420c -[UIKeyboardTaskQueue continueExecutionOnMainThread]
12 UIKitCore +0x9d518c -[UIKeyboardScheduledTask handleDeferredTimerFiredEvent]
13 CoreFoundation +0x12a8f0 ___invoking___
14 CoreFoundation +0x1df4 -[NSInvocation invoke]
15 UIKitCore +0xfa5778 -[_UIActionWhenIdle invoke]
16 CoreFoundation +0xa0354 ___CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__
17 CoreFoundation +0x9a5c0 ___CFRunLoopDoObservers
18 CoreFoundation +0x9ab70 ___CFRunLoopRun
19 CoreFoundation +0x9a218 _CFRunLoopRunSpecific
20 GraphicsServices +0x3780 _GSEventRunModal
21 UIKitCore +0xbc8ee4 -[UIApplication _run]
22 UIKitCore +0xbce758 _UIApplicationMain
23 Wizard-of-Oz +0x20f8268 main (main.mm:38:19)
24 libdyld.dylib +0x16ac _start
I have a UIImageView and a bottom container view inside a UIScrollView.
I set the scrollView's contentInsetAdjustmentBehavior to .never because I want the scrollView's content to anchor to top of the view, such that the content of the scroll view, in this case the imageView, shows inside the top safe area.
The ImageView currently shows all the way to the top. However, the problem is that when the user scrolls down, and the bottomContainer view meets the top Safe Area, the top of the bottomContainer view stretches. The bottom container has all its constraint set for its subviews, from top to bottom. I don't understand why the bottomContainer view would stretch vertically.
The constraint for these views are as follows:
// adds view as subview with `translatesAutoResizingMasksIntoConstraints = false
self.view.add(subviews: mainScrollView)
NSLayoutConstraint.activate([
self.mainScrollView.topAnchor.constraint(equalTo: self.view.topAnchor),
self.mainScrollView.bottomAnchor.constraint(equalTo: self.view.bottomAnchor),
self.mainScrollView.leftAnchor.constraint(equalTo: self.view.leftAnchor),
self.mainScrollView.rightAnchor.constraint(equalTo: self.view.rightAnchor),
self.mainScrollView.contentLayoutGuide.widthAnchor.constraint(equalTo: self.view.widthAnchor)
])
// adds views as subviews with `translatesAutoResizingMasksIntoConstraints = false
self.mainScrollView.add(subviews: [self.profileImageView, self.bottomContainer])
// adds constraints to caller view's edges on axis
self.mainScrollView.make(views: [self.profileImageView, self.bottomContainer], flushAlongAxes: [.horizontal])
// Adds VLF constraints to views on the callers edges
self.mainScrollView.addConstraints(
withVisualFormat: "V:|[profileView(\(self.profileViewHeight))]-(-10)-[bottomContainer]-15-|",
views: ["profileView": self.profileImageView, "bottomContainer": self.bottomContainer])
I will attach a some screenshots to clarify what is happening:
Here is how it is supposed to look:
Here is how it stretches as the bottomContainer scrolls under the SafeArea:
How do I prevent the bottomContainer from stretching when it scrolls under the top safe area?
I'm creating a Netflix like app on tvOS, here is my compositional layout that I use with my collectionView.
private func createLayout() -> UICollectionViewCompositionalLayout {
return UICollectionViewCompositionalLayout { (section, _) -> NSCollectionLayoutSection? in
// item
let itemSize = NSCollectionLayoutSize(widthDimension: .fractionalWidth(1),
heightDimension: .fractionalHeight(1.0))
let item = NSCollectionLayoutItem(layoutSize: itemSize)
item.contentInsets = NSDirectionalEdgeInsets(top: 0, leading: 10, bottom: 0, trailing: 10)
// group
let groupSize = NSCollectionLayoutSize(widthDimension: .fractionalWidth(1/5),
heightDimension: .estimated(350))
let group = NSCollectionLayoutGroup.horizontal(layoutSize: groupSize, subitems: [item])
// section
let section = NSCollectionLayoutSection(group: group)
section.orthogonalScrollingBehavior = .groupPaging
let headerSize = NSCollectionLayoutSize(widthDimension: .fractionalWidth(1.0),
heightDimension: .estimated(UIFont(name: "MyFont", size: 36)!.lineHeight))
let sectionHeader = NSCollectionLayoutBoundarySupplementaryItem(
layoutSize: headerSize,
elementKind: "SectionHeader",
alignment: .top)
section.boundarySupplementaryItems = [sectionHeader]
section.contentInsets = NSDirectionalEdgeInsets(top: 0, leading: 20, bottom: 30, trailing: 0)
return section
}
}
So:
My collection view is composed by several row (that are the sections).
Each section is composed by groups containing 1 item each.
Each section can be scrolled horizontally.
And you can scroll vertically to move from a section to an other.
I'm expecting to have the following behavior when scrolling: Horizontal scrolling:
Before focus shifts
--------------------------
| vA vB vC vD vE |
| [v1] v2 v3 v4 v5 |
| vU vW vX vY vZ |
--------------------------
After focus shifts
--------------------------
| vA vB vC vD vE |
| [v2] v3 v4 v5 v6 |
| vU vW vX vY vZ |
--------------------------
Vertical scroll:
Before focus shifts
--------------------------
| [vA] vB vC vD vE |
| v1 v2 v3 v4 v5 |
| vU vW vX vY vZ |
--------------------------
After focus shifts
--------------------------
| [v1] v2 v3 v4 v5 |
| vU vW vX vY vZ |
| vF vG vH vI vJ |
--------------------------
Thanks to section.orthogonalScrollingBehavior = .groupPaging the horizontal scrolling is working as expected. (I've put 1 item per group to achieve this)
But I'm going crazy with the vertical scroll, I'm not able to achieve it as expected, the focused section still centered verticaly on the screen ! What I'm getting:
Before focus shifts
--------------------------
| [vA] vB vC vD vE |
| v1 v2 v3 v4 v5 |
| vU vW vX vY vZ |
--------------------------
After focus shifts
--------------------------
| vA vB vC vD vE |
| [v1] v2 v3 v4 v5 |
| vU vW vX vY vZ |
--------------------------
After an other focus shifts
--------------------------
| v1 v2 v3 v4 v5 |
| [vU] vW vX vY vZ |
| vF vG vH vI vJ |
--------------------------
I've tried to play with the didUpdateFocusIn function without success
func collectionView(_ collectionView: UICollectionView, didUpdateFocusIn context: UICollectionViewFocusUpdateContext, with coordinator: UIFocusAnimationCoordinator) {
if let nextFocusedItemIndexPath = context.nextFocusedIndexPath {
let section = nextFocusedItemIndexPath.section
let sectionIndexPath = IndexPath(item: 0, section: section)
collectionView.scrollToItem(at: sectionIndexPath, at: .top, animated: true)
}
}
The collectionview is behaving strangely when using the didUpdateFocusIn function and I feel it's not the good way to perform what I'm expecting...
I've also try to play with the scrollViewWillEndDragging function without success
func scrollViewWillEndDragging(_ scrollView: UIScrollView, withVelocity velocity: CGPoint, targetContentOffset:
}
Everything that I tried looks like a hack and I can't believe Apple has not plan something for this use case, which is in my sense a common use case....