I am trying to self size DTAttributedTextContentView inside the collection cell based on its attributed text. The problem I face is that when I set attributedTextContentView width constraints like so:
attributedTextContentView.widthAnchor.constraint(lessThanOrEqualToConstant: 260)
it applies the whole constant width (in this case 260) to the textContentView, even if attributedString length is smaller than the width, leaving some extra space:
My question is, how to size the frame of DTAttributedTextContentView so that it just encloses the text that it contains?
Initially I used basic UITextView, but the scrolling of cells through collection view is not that smooth when there are multiple cells, and also it gives possibility to easy access the last line of the text inside, which I need for my app, so I would like to stick to DTAttributedTextContentView.
Here is the sample code for testing:
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
configureCollectionView()
}
// MARK: - Collection view setup
let collectionView: UICollectionView = {
let layout = UICollectionViewCompositionalLayout { (section, environment) -> NSCollectionLayoutSection? in
let itemSize = NSCollectionLayoutSize(widthDimension: .fractionalWidth(1.0), heightDimension: .estimated(10))
let item = NSCollectionLayoutItem(layoutSize: itemSize)
let group = NSCollectionLayoutGroup.vertical(layoutSize: itemSize, subitems: [item])
let section = NSCollectionLayoutSection(group: group)
section.interGroupSpacing = 5
return section
}
layout.configuration.scrollDirection = .vertical
let collectionView = UICollectionView(frame: .zero, collectionViewLayout: layout)
collectionView.register(ConversationCollectionViewCell.self, forCellWithReuseIdentifier: "ConversationCell")
return collectionView
}()
private func configureCollectionView() {
collectionView.dataSource = self
collectionView.backgroundColor = .brown
view.addSubview(collectionView)
collectionView.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
collectionView.leadingAnchor.constraint(equalTo: view.leadingAnchor),
collectionView.trailingAnchor.constraint(equalTo: view.trailingAnchor),
collectionView.topAnchor.constraint(equalTo: view.topAnchor),
collectionView.bottomAnchor.constraint(equalTo: view.bottomAnchor)
])
}
}
// MARK: - Collection Data Source
extension ViewController: UICollectionViewDataSource {
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return 10
}
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "ConversationCell", for: indexPath) as! ConversationCollectionViewCell
return cell
}
}
// MARK: - Collection View Custon Cell
final class ConversationCollectionViewCell: UICollectionViewCell, DTAttributedTextContentViewDelegate {
var mainCellContainerView = UIView()
var attributedTextContentView = DTAttributedTextContentView()
//MARK: - LIFECYCLE
override init(frame: CGRect) {
super.init(frame: frame)
setupmainCellContainerView()
setupAttributedTextContentView()
layoutIfNeeded()
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
// MARK: - UI STEUP
private func setupmainCellContainerView() {
contentView.addSubview(mainCellContainerView)
mainCellContainerView.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
mainCellContainerView.topAnchor.constraint(equalTo: contentView.topAnchor),
mainCellContainerView.bottomAnchor.constraint(equalTo: contentView.bottomAnchor),
mainCellContainerView.leadingAnchor.constraint(equalTo: contentView.leadingAnchor),
mainCellContainerView.trailingAnchor.constraint(equalTo: contentView.trailingAnchor),
])
}
private func setupAttributedTextContentView() {
mainCellContainerView.addSubview(attributedTextContentView)
attributedTextContentView.backgroundColor = .systemIndigo
attributedTextContentView.delegate = self
attributedTextContentView.sizeToFit()
let attributedString = NSAttributedString(string: "Simple message for testing purpose @", attributes: [
.font: UIFont(name: "HelveticaNeue", size: 17),
.foregroundColor: UIColor.white,
.paragraphStyle: {
let paragraphStyle = NSMutableParagraphStyle()
paragraphStyle.alignment = .left
paragraphStyle.lineBreakMode = .byWordWrapping
return paragraphStyle
}()
])
attributedTextContentView.attributedString = attributedString
attributedTextContentView.contentMode = .redraw
attributedTextContentView.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
attributedTextContentView.widthAnchor.constraint(lessThanOrEqualToConstant: 260),
attributedTextContentView.topAnchor.constraint(equalTo: mainCellContainerView.topAnchor),
attributedTextContentView.bottomAnchor.constraint(equalTo: mainCellContainerView.bottomAnchor),
])
}
}
UIKit
RSS for tagConstruct and manage graphical, event-driven user interfaces for iOS or tvOS apps using UIKit.
Post
Replies
Boosts
Views
Activity
Hello, I have created a documentspicker to select a PDF file and then upload it to storage, but I am getting this error only on my device; it works correctly on the simulator.
This is my code:
@Binding var alertShow:Bool
var detailpet:String = ""
func makeCoordinator() -> Coordinator {
return DocumentPicker.Coordinator(parent1: self)
}
func makeUIViewController(context: UIViewControllerRepresentableContext<DocumentPicker>) -> UIDocumentPickerViewController {
let picker = UIDocumentPickerViewController(forOpeningContentTypes: [.pdf])
picker.allowsMultipleSelection = false
picker.delegate = context.coordinator
return picker
}
func updateUIViewController(_ uiViewController: UIDocumentPickerViewController, context: UIViewControllerRepresentableContext<DocumentPicker>) {
}
class Coordinator : NSObject, UIDocumentPickerDelegate {
var parent:DocumentPicker
init(parent1: DocumentPicker){
parent = parent1
}
func documentPicker(_ controller: UIDocumentPickerViewController, didPickDocumentsAt urls:[URL]) {
let bucket = Storage.storage().reference()
let db = Firestore.firestore()
let collection = "documents"
guard let url = urls.first, url.startAccessingSecurityScopedResource() else {
return
}
DispatchQueue.main.async {
url.stopAccessingSecurityScopedResource()
print("Documents Picker stop")
}
let referenceDocument = bucket.child("docu/\(url.deletingPathExtension().lastPathComponent)")
let _ = referenceDocument.putFile(from:url, metadata: nil) {
metadata , error in
guard metadata != nil else{
print("Error \(String(describing: error?.localizedDescription))")
return
}
referenceDocument.downloadURL { url, error in
guard let url = url else {
print("Message error \(String(describing: error?.localizedDescription))")
return
}
let _ = try? db.collection(collection).addDocument(from:DocumentData(idpet:self.parent.detailpet, name: "\(url.deletingPathExtension().lastPathComponent).pdf", url: url.absoluteString))
}
print("Succes")
self.parent.alertShow.toggle()
}
}
}
}
t seems to be a permissions issue, I believe. Do you know how I can fix this? It's my first application. Thank you.
Hi everyone,
I'm having issue with UITabBarItem's selectedImage is not working only on iOS 12.
Image is in PNG format, already tried with PDF single scale but result still the same.
let vc = HomeViewController.storyboardInstance()
let tabBarItem = UITabBarItem(title: "home".localized(), image: UIImage(named: "tabbar.home.selected"), selectedImage: UIImage(named: "tabbar.home.selected"))
tabBarItem.updateFont()
vc.tabBarItem = tabBarItem
return CustomNavigationController(rootViewController: vc)
I also want to mention that image is working fine with original color (render as Original Image) but selectedImage (render as Original Image) with original color doesn't work.
Does anyone here know what is the problem ?
The structure of the UI is a bit complicated. I'll do my best to explain. There is a UITableView that has a sibling in its view hierarchy. Footer buttons that come on top of the UITableView at the bottom of the screen. I am using a one finger swipe gesture to iterate over different elements on the page and in the table view.
Each cell in the UITableView has a UIViewController which has a UICollectionView. This UICollectionView has cells that have multiple views nested inside with most of them being dummy views. The cells have different structures and the voice over works well across them without any customisation and is able to identify all the right accessibility elements. Now the problem comes in the last cell on the page.
Imagine it has 2 UILabels and 2 UIButtons. When navigating using normal voice over and not defining any accessibilityElements, the order is weird so I added
override var accessibilityElements: [Any]?{
get{
return [label1, button1, label2, button2]
}set {}
When navigating to this cell, everything works fine but once an element inside this particular last cell is highlighted it gets messed up. The order works fine but the voice over ends up looping inside the cell. It doesn't go back to the other cells or navigate to the footer of the page. If I remove the accessibilityElements array then everything is fine but not in the correct order.
Anybody know why that might be and how to break the loop? It would be helpful if I could know how voice over recognises which view to navigate to next.
We have developed an iOS app using three fonts: PingFangSC Regular, PingFangSC Medium, and DINAlternate-Bold. Do all three fonts require commercial authorization to be used in the 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.
I have the following crash in swiftui that relates to memory reallocation, which I am not sure how to handle
Crash.txt
We are noticing below iOS crash majorly happening from iOS 17 version. Can someone please check and let me know what might be causing this crash and how to solve this? Attached full crash report from app store.
Last Exception Backtrace:
0 CoreFoundation 0x1b5cce69c __exceptionPreprocess + 164 (NSException.m:249)
1 libobjc.A.dylib 0x1adf67c80 objc_exception_throw + 60 (objc-exception.mm:356)
2 UIKitCore 0x1b8592ab4 -[UIViewController _presentViewController:withAnimationController:completion:] + 4236 (UIViewController.m:0)
3 UIKitCore 0x1b859312c __63-[UIViewController _presentViewController:animated:completion:]_block_invoke + 92 (UIViewController.m:9730)
4 UIKitCore 0x1b7f36fac -[_UIViewControllerTransitionCoordinator _applyBlocks:releaseBlocks:] + 128 (UIViewControllerTransitioning.m:1205)
5 UIKitCore 0x1b7f36ab4 -[_UIViewControllerTransitionContext _runAlongsideCompletions] + 140 (UIViewControllerTransitioning.m:393)
6 UIKitCore 0x1b7f36144 -[_UIViewControllerTransitionContext completeTransition:] + 128 (UIViewControllerTransitioning.m:307)
7 UIKitCore 0x1b80a9460 -[UITransitionView notifyDidCompleteTransition:] + 180 (UITransitionView.m:280)
8 UIKitCore 0x1b80a9118 -[UITransitionView _didCompleteTransition:] + 832 (UITransitionView.m:249)
9 UIKitCore 0x1b7e91d78 UIVIEW_IS_EXECUTING_ANIMATION_COMPLETION_BLOCK + 36 (UIView.m:16376)
10 UIKitCore 0x1b7e91510 -[UIViewAnimationBlockDelegate _didEndBlockAnimation:finished:context:] + 624 (UIView.m:16409)
11 UIKitCore 0x1b7e90b88 -[UIViewAnimationState sendDelegateAnimationDidStop:finished:] + 436 (UIView.m:0)
12 UIKitCore 0x1b7e72d84 -[UIViewAnimationState animationDidStop:finished:] + 196 (UIView.m:2407)
13 UIKitCore 0x1b7e72e98 -[UIViewAnimationState animationDidStop:finished:] + 472 (UIView.m:2426)
14 QuartzCore 0x1b725f980 run_animation_callbacks(void*) + 132 (CALayer.mm:7713)
15 libdispatch.dylib 0x1bdbd9300 _dispatch_client_callout + 20 (object.m:561)
16 libdispatch.dylib 0x1bdbe7998 _dispatch_main_queue_drain + 984 (queue.c:7813)
17 libdispatch.dylib 0x1bdbe75b0 _dispatch_main_queue_callback_4CF + 44 (queue.c:7973)
18 CoreFoundation 0x1b5c1901c CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE + 16 (CFRunLoop.c:1780)
19 CoreFoundation 0x1b5c15d28 __CFRunLoopRun + 1996 (CFRunLoop.c:3149)
20 CoreFoundation 0x1b5c15478 CFRunLoopRunSpecific + 608 (CFRunLoop.c:3420)
21 GraphicsServices 0x1f91964f8 GSEventRunModal + 164 (GSEvent.c:2196)
22 UIKitCore 0x1b803962c -[UIApplication _run] + 888 (UIApplication.m:3685)
23 UIKitCore 0x1b8038c68 UIApplicationMain + 340 (UIApplication.m:5270)
24 UnityFramework 0x11151c310 -[UnityFramework runUIApplicationMainWithArgc:argv:] + 92 (main.mm:124)
25 myapp 0x10497c17c main + 60 (main.mm:26)
26 dyld 0x1d894edcc start + 2240 (dyldMain.cpp:1269)
Kernel Triage:
VM - (arg = 0x3) mach_vm_allocate_kernel failed within call to vm_map_enter
VM - (arg = 0x3) mach_vm_allocate_kernel failed within call to vm_map_enter
VM - (arg = 0x3) mach_vm_allocate_kernel failed within call to vm_map_enter
VM - (arg = 0x3) mach_vm_allocate_kernel failed within call to vm_map_enter
VM - (arg = 0x3) mach_vm_allocate_kernel failed within call to vm_map_enter
Thread 0 name:
Thread 0 Crashed:
0 libsystem_kernel.dylib 0x00000001fd349fbc __pthread_kill + 8 (:-1)
1 libsystem_pthread.dylib 0x000000021fc0b680 pthread_kill + 268 (pthread.c:1681)
2 libsystem_c.dylib 0x00000001bdc91c24 __abort + 136 (abort.c:159)
3 libsystem_c.dylib 0x00000001bdc91b9c abort + 192 (abort.c:126)
4 libc++abi.dylib 0x000000021fb35ff8 abort_message + 132 (abort_message.cpp:78)
5 libc++abi.dylib 0x000000021fb25f90 demangling_terminate_handler() + 348 (cxa_default_handlers.cpp:77)
6 libobjc.A.dylib 0x00000001adf6ada4 _objc_terminate() + 144 (objc-exception.mm:496)
7 UnityFramework 0x000000011358d254 CPPExceptionTerminate() + 332 (BSG_KSCrashSentry_CPPException.mm:137)
8 libc++abi.dylib 0x000000021fb353bc std::__terminate(void (*)()) + 16 (cxa_handlers.cpp:59)
9 libc++abi.dylib 0x000000021fb35360 std::terminate() + 108 (cxa_handlers.cpp:88)
10 libdispatch.dylib 0x00000001bdbd9314 _dispatch_client_callout + 40 (object.m:564)
11 libdispatch.dylib 0x00000001bdbe7998 _dispatch_main_queue_drain + 984 (queue.c:7813)
12 libdispatch.dylib 0x00000001bdbe75b0 _dispatch_main_queue_callback_4CF + 44 (queue.c:7973)
13 CoreFoundation 0x00000001b5c1901c CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE + 16 (CFRunLoop.c:1780)
14 CoreFoundation 0x00000001b5c15d28 __CFRunLoopRun + 1996 (CFRunLoop.c:3149)
15 CoreFoundation 0x00000001b5c15478 CFRunLoopRunSpecific + 608 (CFRunLoop.c:3420)
16 GraphicsServices 0x00000001f91964f8 GSEventRunModal + 164 (GSEvent.c:2196)
17 UIKitCore 0x00000001b803962c -[UIApplication _run] + 888 (UIApplication.m:3685)
18 UIKitCore 0x00000001b8038c68 UIApplicationMain + 340 (UIApplication.m:5270)
19 UnityFramework 0x000000011151c310 -[UnityFramework runUIApplicationMainWithArgc:argv:] + 92 (main.mm:124)
20 myapp 0x000000010497c17c main + 60 (main.mm:26)
21 dyld 0x00000001d894edcc start + 2240 (dyldMain.cpp:1269)
NSInvalidArgumentException.txt
I'm testing Full Keyboard Access in my app and on the iPhone apps in my iPhone 12 mini with OS 17. My work will directly impact how much accessibility review is done on our iOS app which has millions of unique views a month.
In several Apple apps I cannot seem to scroll down through the screen when the main View has focus.
For example,
the Home app does not scroll with arrow keys nor Ctrl+tab through any of the 6 main content groups on the Discover screen. it almost appears it's a single static image; the "Getting Started" button is not able to be activated. I can activate sections further down when I enable gestures, but cannot pinpoint a specific location.
The Stocks app includes Top Stories from the Apple News app; in either app I can select a story, which brings up the article on full screen, but then I cannot use the arrow keys or Ctrl+tab to read the article or interact with inline links. Ctrl + tab selects the button features like to watch an embedded video or live coverage, then jumps down to the end of the article to focus on Related stories, ignoring all the links in between.
I am able to somewhat move through the article text with keyboard gestures, but many of these articles have embedded links or content after the article (before "Related Stories"
I work in digital accessibility and need to be able to tell my teams what is expected behavior and where to see examples of this. If Apple can't demonstrate Full Keyboard Access in its own apps this is a problem.
Our own app has some of these issues but I am unsure how to recommend a solution when the scrollview seems to not work in native iOS apps by Apple.
Hello,
Since the full keyboard access Help menu is a little vague on the nuances between Tab, arrow keys, and Ctrl+tab in terms of navigation, could you point me to where I can find the intended mapping of FKA keys to UI elements?
For example, I have been in several Apple iOS apps where the UITabBar at the bottom is navigable with any of the three options mentioned above. In other contexts, the tab key only moves the user to the tab bar section, then the icons are focusable with arrow or Ctrl + tab.
When a modal pops up stating I will be leaving an app, should the choices be navigable with Tab? Ctrl+tab? or arrows too?
In other places, like news articles in Apple News, it seems that I cannot scroll with the arrow keys to read the various paragraphs, nor interact with links at all that are in the article. If there is a separate keyboard shortcut for links or scrollbar, please update the Help menu.
It seems pretty straightforward that arrow keys navigate between HStacks and VStacks. Is that an accurate guess of arrow key behavior? I feel like I'm guessing in several places within the content groups.
When a VC dissapears that contained a textfiled with:
textField.textContentType = .password
I get the dialog "Would you like to save the password to iCloud keychain". If I send the app to background without dismissing the dialog first, and I get the app to foreground again, the dialog is not there but when I press any textfield inside the app the keyboard wont raise. Seems to be an iOS 13+ issue. Any help?
Hi! I'm moving my UINavigationBar and UINavigationItem to the iOS 16 style and having trouble with disabling buttons.
Before:
I'm defining rightBarButtonItems with a few barButtonItems plus a (custom) menuButtonItem (which has a menu with some more actions).
After:
I'm defining trailingItemGroups and let the system create an overflow menu dynamically, depending on space. I'm also defining some additionalOverflowItems.
Here's the problem:
How can I access the button/barButtonItem that is showing the overflow menu and call isEnabled = false? My UI, so far, has disabled all buttons during edit mode. I don't want to hide them, but have them grayed out, including the overflow menu button.
class MyVC : UIViewController {
// ...
override func setEditing(_ editing: Bool, animated: Bool) {
super.setEditing(editing, animated: animated)
// ...
// This doesn't disable the overflow menu button
navigationItem
.trailingItemGroups
.forEach {
$0.barButtonItems
.forEach {
$0.isEnabled = !isEditing
}
}
}
}
I've encountered a memory leak issue when setting the prefersGrabberVisible to true as shown below. There seems to be a bug where the view controller is not properly released from memory upon dismissal.
if let sheet = presentedViewController.sheetPresentationController {
sheet.detents = g_detents(defaultHeight: defaultHeight)
sheet.prefersScrollingExpandsWhenScrolledToEdge = false
sheet.prefersEdgeAttachedInCompactHeight = true
sheet.widthFollowsPreferredContentSizeWhenEdgeAttached = true
sheet.prefersGrabberVisible = true // Commenting out this line prevents the memory leak
sheet.selectedDetentIdentifier = .medium
}
present(presentedViewController, animated: true, completion: nil)
Has anyone else experienced this issue, or does anyone have a workaround for this memory leak problem? Any insights or suggestions would be greatly appreciated.
struct SettingsList {
var image: UIImage!
var settingsName: String
var settingsButton: String
}
class SettingsTableViewCell: UITableViewCell {
static let reuseID = "note_cell"
private lazy var settingImageView: UIImageView = {
let view = UIImageView()
return view
}()
private lazy var settingTitleLabel: UILabel = {
let view = UILabel()
view.font = UIFont.preferredFont(forTextStyle: .body)
view.textColor = UIColor.label
return view
}()
var button: UIButton = {
let view = UIButton(type: .system)
view.setImage(UIImage(named: "Chevron"), for: .normal)
view.setTitle("Русский", for: .normal)
view.setTitleColor(.secondaryLabel, for: .normal)
view.tintColor = .black
view.semanticContentAttribute = .forceRightToLeft
view.imageEdgeInsets = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: -15)
return view
}()
var switchButton: UISwitch = {
let view = UISwitch()
return view
}()
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
contentView.backgroundColor = .secondarySystemBackground
contentView.addSubview(settingImageView)
contentView.addSubview(settingTitleLabel)
contentView.addSubview(button)
contentView.addSubview(switchButton)
setupLayout()
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override func prepareForReuse() {
super.prepareForReuse()
settingImageView.image = nil
settingTitleLabel.text = nil
}
func setup(title: String) {
settingTitleLabel.text = title
}
func setup(image: UIImage) {
settingImageView.image = image
}
private func setupLayout() {
settingImageView.snp.makeConstraints { make in
make.centerY.equalTo(contentView)
make.leading.equalTo(contentView).offset(16)
make.width.height.equalTo(24)
}
settingTitleLabel.snp.makeConstraints { make in
make.centerY.equalTo(contentView)
make.leading.equalTo(settingImageView.snp.trailing).offset(13)
}
button.snp.makeConstraints { make in
make.centerY.equalTo(contentView)
make.trailing.equalTo(contentView).offset(-25)
}
switchButton.snp.makeConstraints { make in
make.centerY.equalTo(contentView)
make.trailing.equalTo(contentView).offset(-25)
}
}
}
import UIKit
class SettingsVC: UIViewController {
private let settingsTableView = UITableView()
let settingsList: [SettingsList] = [
SettingsList(image: UIImage(named: "language"), settingsName: "Язык", settingsButton: "chevron.right"),
SettingsList(image: UIImage(named: "moon"), settingsName: "Темная тема", settingsButton: "switch.2"),
SettingsList(image: UIImage(named: "trash"), settingsName: "Очистить данные", settingsButton: "")
]
override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = .systemBackground
setupUI()
}
private func setupUI(){
setupNavigationItem()
settingsTableView.register(SettingsTableViewCell.self, forCellReuseIdentifier: SettingsTableViewCell.reuseID)
}
private func setupNavigationItem() {
navigationItem.title = "Settings"
let image = UIImage(named: "settings")
let resizedImage = image?.resized(to: CGSize(width: 25, height: 25))
let rightBarButtonItem = UIBarButtonItem(image: resizedImage, style: .plain, target: self, action: #selector(settingsButtonTapped))
rightBarButtonItem.tintColor = .black
navigationItem.rightBarButtonItem = rightBarButtonItem
}
@objc func settingsButtonTapped(_ sender: UIButton){
}
}
extension SettingsVC: UITableViewDataSource {
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
settingsList.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: SettingsTableViewCell.reuseID, for: indexPath) as! SettingsTableViewCell
print("Configuring cell for row \(indexPath.row)")
if indexPath.row == 0 {
cell.contentView.addSubview(cell.button)
} else {
cell.button.removeFromSuperview()
}
if indexPath.row == 1 {
cell.contentView.addSubview(cell.switchButton)
} else {
cell.switchButton.removeFromSuperview()
}
cell.setup(title: settingsList[indexPath.row].settingsName)
cell.setup(image: settingsList[indexPath.row].image)
return cell
}
}
It doesn't work when I click on this page(Settings.VC), It gives an error Thread 1: breakpoint 1.1 4.1 (1) and I don't know how to fix this;(((
What I want to develop is this one:
I wanted to implement a feature that allows the sharing of multiple files simultaneously to my app from an external app like Files.
In my ApplicationDelegate file, I provided the following method, which currently only retrieves a single file URL from the share sheet, even when multiple files were selected in the Files app:
- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options {
return [self handleSharedURL:url options:options];
}
I'm curious to know if there is a way to obtain multiple file URLs without relying on a share extension. Any advice would be greatly appreciated.
I wanted to implement a feature that allows the sharing of multiple files simultaneously to my app from an external app like Files.
In my ApplicationDelegate file, I provided the following method, which currently only retrieves a single file URL from the share sheet, even when multiple files were selected in the Files app:
- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options {
return [self handleSharedURL:url options:options];
}
I'm curious to know if there is a way to obtain multiple file URLs without relying on a share extension. Any advice would be greatly appreciated.
I have form fields in an app, I have some validations to perform like phone number should only have digits and not alphabets, however when user uses AutoFill option doing long press on textfield they have option to choose Contacts and they can tap on name and it will paste alphabets in my Phone number field, that behavior I don't want as my validations will not be fulfilled. There are no callbacks to detect and prevent that text from being pasted.
In shouldChangeCharactersIn delegate method even if I return false for that paste event it ignores that and forcefully it gets pasted.
Please help how to tackle such scenarios to perform above mentioned validations.
Thanks
I’d like to add text in my dialogs to explain features and then hide the text and shrink the dialog after it’s been seeN. Is there are show/hide or a more/less function that can be used in dialogs?
For instance, executing the following code, in which a stepper is injected in a table view cell and the cell is reloaded when the user changes the stepper's value, causes the memory usage to grow pretty quickly (I stopped the simulation at 1GB) when you tap on the stepper.
Also the CPU usage jumps straight at 99%, and the UI freezes.
Note: I'd like to know exactly what I asked, not how to make a table view cell with a stepper in general.
I know that calling reloadData() or reconfigureRows(at:) doesn't cause any of the mentioned issues.
Also please don't reply with questions like "Have you tried to use weak references?".
The code is short: please reply with a working solution if you can.
class ViewController: UIViewController {
let tableView = UITableView()
let stepper = UIStepper()
override func viewDidLoad() {
super.viewDidLoad()
view.addSubview(tableView)
tableView.register(UITableViewCell.self, forCellReuseIdentifier: "cell")
tableView.dataSource = self
stepper.addTarget(self, action: #selector(stepperValueChanged), for: .valueChanged)
}
override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
tableView.frame = view.bounds
}
@objc private func stepperValueChanged() {
tableView.reloadRows(at: [IndexPath(row: 0, section: 0)], with: .automatic)
}
}
extension ViewController: UITableViewDataSource {
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
1
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath)
cell.accessoryView = stepper
var configuration = cell.defaultContentConfiguration()
configuration.text = "\(stepper.value)"
cell.contentConfiguration = configuration
return cell
}
}
On app minor update, after moving to xcode 15.2
Any thoughts on what could be causing it?
Thank you in advance.