Hi, i'm new to ios development. Can someone give some example to how to use the Metacharacters in RegularExpression pattern?
var regex = try! NSRegularExpression(pattern: "[\D]", options:[])
this shows invalid escape sequence in literal error
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
Hi folks,
I tried to use apple's text recognition feature by using UIAction.captureTextFromCamera(responder:identifier:). It works fine in iPhone and iPad 3rd Gen. But in iPad 4th Gen the action is not get triggered. Kindly provide assistance .
if #available(iOS 15.0, *), self.canPerformAction(#selector(captureTextFromCamera(_:)), withSender: self) {
let cameraAction = UIAction.captureTextFromCamera(responder: self, identifier: nil)
let cameraButton = UIButton(type: .custom)
cameraButton.addAction(cameraAction, for: .touchUpInside)
cameraButton.setTitle("Scan-Text", for: .normal)
view.addSubview(cameraButton)
// Then set constraints
}
_Note: The button to trigger the action is visible only the action is not get triggered.
_
Device specs:
Name: iPad Air 4th Gen
Os : iOS 16
Hi I tried to use compositional layout, while using stage manager rare the app getting crashed. Please refer below error message
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid absolute dimension: inf. The dimension must be a finite value.'
let itemSize = NSCollectionLayoutSize(widthDimension: .absolute(cellWidth),heightDimension: .absolute(cellHeight))
let item = NSCollectionLayoutItem(layoutSize: itemSize)
let groupSize = NSCollectionLayoutSize(widthDimension: .fractionalWidth(1), heightDimension: .absolute(cellHeight))
let group = NSCollectionLayoutGroup.horizontal(layoutSize: groupSize, subitems: [item])
group.interItemSpacing = NSCollectionLayoutSpacing.fixed(cellSpacing)
let section = NSCollectionLayoutSection(group: group)
section.contentInsets = NSDirectionalEdgeInsets(top: 10,leading: inset, bottom: 0,trailing:inset)
section.interGroupSpacing = lineSpacing
Why am I getting this error after providing exact height and width?
I tried to implement interaction to live activity.Since we don't have force update like in widget, how to update the UI (like remove or add View) After performing the intent action.
Topic:
App & System Services
SubTopic:
Notifications
Tags:
ActivityKit
wwdc2023-10185
wwdc2023-10194
Is it possible to get enabled status of app's live activity through areActivitiesEnabled inside other targets (other than main target)? seems it always returns true.
Topic:
App & System Services
SubTopic:
Notifications
Tags:
ActivityKit
wwdc2023-10185
wwdc2023-10194
I tried to add iOS 17 version check inside WidgetBundle but the widget extension keep on crashing .
Getting Thread 1: Swift runtime failure: Unexpectedly found nil while unwrapping an Optional value. After removing the iOS 17 check it works fine.
Is there any way to provide version check inside widgetBundle?
To enable editing in the elevated Tab Bar or sidebar on iPadOS, we need to use UITabBar. However, using UITabBar restricts reordering in compact mode with the bottom tab bar. Instead of showing the tabs, the editing view only displays the message 'Drag the icons to organize tabs.' How can we resolve this issue?
Find demo project here
All errors in TranslationError return the same error code, making it difficult to differentiate between them. How can this issue be resolved?
Topic:
Machine Learning & AI
SubTopic:
Core ML
Tags:
Swift Student Challenge
iOS
Machine Learning
Core ML
I’m currently focused on an element at the bottom of the screen. What is the proper way to quickly navigate to the top element? By default, there’s a four-finger single tap to move to the first element, but should I use the Rotor action instead to focus on the element I need?
For example, in the Contacts app while adding a new contact, if I enter a value in a field at the bottom, there’s no quick way to directly save the contact. I have to manually navigate all the way to the top to tap the Done button, which feels a bit inconvenient.
Is there a better way to handle this using VoiceOver?
VoiceOver reads out all visible content on the screen, which is essential for visually challenged users. However, this raises a privacy concern—what if a user accidentally focuses on sensitive information, like a bank account password, and it gets read aloud?
How can developers prevent VoiceOver from exposing confidential data while still maintaining accessibility? Are there best practices or recommended approaches to handle such scenarios effectively?
In VoiceOver, when using Group Navigation style, the cursor first focuses on the semantic group. To navigate inside the group, a two-finger swipe (left or right) can be used. This behavior works for default containers like the Navigation Bar, Tab Bar, and Tool Bar.
How can I achieve the same behavior for a custom view?
I tried setting accessibilityContainerType = .semanticGroup, but it only works for Mac Catalyst. Is there an equivalent approach for iOS?
I’m trying to add the .header accessibility trait to a UISegmentedControl so that VoiceOver recognizes it accordingly. However, setting the trait using the following code doesn’t seem to have any effect:
segmentControl.accessibilityTraits = segmentControl.accessibilityTraits.union(.header)
Even after applying this, VoiceOver doesn’t announce it as a header. Is there any workaround or recommended approach to achieve this?
I have a UIImageView as the background of a custom UIView subclass. The image itself does not contain any text. On top of this image view, I have added two UILabels.
To improve accessibility, I converted the entire view into a single accessibility element and set a proper accessibilityLabel. Additionally, I disabled accessibility for the UIImageView and the labels by setting isAccessibilityElement = false.
However, when VoiceOver's Accessibility Recognition's Text Recognition feature is enabled, VoiceOver still detects and announces the text inside the UILabels at the end after reading my custom accessibility properties. This text should not be announced.
It seems that VoiceOver treats the UILabel content as part of the UIImageView. Additionally, when using the Explore Image rotor action, the entire subview is recognized as a single image.
Is this the expected behavior? If so, is there a way to disable VoiceOver’s text recognition for this view while keeping custom accessibility intact?
class BackgroundLabelView: UIView {
private let backgroundImageView = UIImageView()
private let backgroundImageView2 = UIImageView()
private let titleLabel = UILabel()
private let subtitleLabel = UILabel()
override init(frame: CGRect) {
super.init(frame: frame)
setupView()
}
required init?(coder: NSCoder) {
super.init(coder: coder)
setupView()
configureAceesibility()
}
private func configureAceesibility() {
backgroundImageView.isAccessibilityElement = false
backgroundImageView2.isAccessibilityElement = false
titleLabel.isAccessibilityElement = false
subtitleLabel.isAccessibilityElement = false
isAccessibilityElement = true
accessibilityTraits = .button
}
func configure(backgroundImage: UIImage?, title: String, subtitle: String) {
backgroundImageView.image = backgroundImage
titleLabel.text = title
subtitleLabel.text = subtitle
accessibilityLabel = "Holiday Offer ," + title + "," + subtitle
}
private func setupView() {
backgroundImageView2.contentMode = .scaleAspectFill
backgroundImageView2.clipsToBounds = true
backgroundImageView2.translatesAutoresizingMaskIntoConstraints = false
backgroundImageView2.image = UIImage(resource: .bannerfestival)
addSubview(backgroundImageView2)
backgroundImageView.contentMode = .scaleAspectFit
backgroundImageView.clipsToBounds = true
backgroundImageView.translatesAutoresizingMaskIntoConstraints = false
addSubview(backgroundImageView)
titleLabel.font = UIFont.systemFont(ofSize: 18, weight: .bold)
titleLabel.textColor = .white
titleLabel.translatesAutoresizingMaskIntoConstraints = false
titleLabel.numberOfLines = 0
addSubview(titleLabel)
subtitleLabel.font = UIFont.systemFont(ofSize: 14, weight: .regular)
subtitleLabel.textColor = .white.withAlphaComponent(0.8)
subtitleLabel.translatesAutoresizingMaskIntoConstraints = false
subtitleLabel.numberOfLines = 0
addSubview(subtitleLabel)
NSLayoutConstraint.activate([
backgroundImageView2.leadingAnchor.constraint(equalTo: leadingAnchor),
backgroundImageView2.trailingAnchor.constraint(equalTo: trailingAnchor),
backgroundImageView2.heightAnchor.constraint(equalToConstant: 200),
backgroundImageView.centerYAnchor.constraint(equalTo: centerYAnchor),
backgroundImageView.topAnchor.constraint(equalTo: topAnchor),
backgroundImageView.leadingAnchor.constraint(greaterThanOrEqualTo: leadingAnchor),
backgroundImageView.trailingAnchor.constraint(equalTo: trailingAnchor),
backgroundImageView.bottomAnchor.constraint(equalTo: bottomAnchor),
titleLabel.leadingAnchor.constraint(equalTo: leadingAnchor, constant: 16),
titleLabel.trailingAnchor.constraint(lessThanOrEqualTo: centerXAnchor),
titleLabel.bottomAnchor.constraint(equalTo: centerYAnchor, constant: -4),
subtitleLabel.leadingAnchor.constraint(equalTo: leadingAnchor, constant: 16),
subtitleLabel.trailingAnchor.constraint(lessThanOrEqualTo: centerXAnchor),
subtitleLabel.topAnchor.constraint(equalTo: centerYAnchor, constant: 4)
])
}
override func layoutSubviews() {
super.layoutSubviews()
backgroundImageView.layer.cornerRadius = layer.cornerRadius
}
}
I have a view dynamically overlaid on a UITableView with proper padding (added when certain conditions are met). When VoiceOver focuses on a cell beneath this overlay, the focused element does not scroll into view. I’ve noticed similar behavior in Apple’s first-party Podcasts app.
Please find the attached image for reference. How can I resolve this issue and ensure VoiceOver scrolls the focused cell into view?
I have some doubts about how VoiceOver handles focus when the screen updates.
When a new UIViewController is pushed onto a UINavigationController or presented modally, how does VoiceOver decide which element to focus on? Is there a way to control or customize this behavior?
In a UISplitViewController, when an item is selected in the primary view controller, the focus should shift to the relevant content in the secondary view controller. How can we ensure that VoiceOver correctly moves focus to the right element in the secondary panel?