I have a stackview which have 2 labels
class TextView: UIView {
@IBOutlet private weak var stackView: UIStackView! {
didSet {
stackView.isAccessibilityElement = true
stackView.accessibilityLabel = label1.text + label2.text
}
}
@IBOutlet private weak var label1: UILabel! {
didSet {
label1.accessibilityIdentifier = "label1"
}
}
@IBOutlet private weak var: UILabel!{
didSet {
label2.accessibilityIdentifier = "label2"
}
}
}
My goal here is to have a combines accessibility label for the stackview and yet able to access the accessibilityIdentifier of child elements for automation.
Post
Replies
Boosts
Views
Activity
I want to expose few elements for accessibility alone and other for automation alone. But I can only accessibility elements in Accessibility Inspector but can't see Automation Elements
self.view.accessibilityElements = [loginButton as Any,
registerButton as Any,
closeButton as Any]
self.view.automationElements = [claimLabel as Any,
loginButton as Any,
registerButton as Any,
intoductionImage as Any,
closeButton as Any])
I have two views in a container view as below
@IBOutlet weak var dataDisclosureView: UIStackView! // Main ContainerView
@IBOutlet private weak var titleLabel: UILabel! {
didSet {
titleLabel.text = "Hello"
}
}
@IBOutlet private weak var descriptionLabel: UILabel! {
didSet {
descriptionLabel.text = "World"
}
}
@IBOutlet weak var descriptionView: UIStackView! { // sub container view containing titleLabel and descriptionLabel
didSet {
descriptionView.isAccessibilityElement = true
descriptionView.accessibilityLabel = "Hello"
descriptionView.accessibilityIdentifier = "test_hello"
}
}
@IBOutlet private weak var requestButton: UIButton! {
didSet {
requestButton.isAccessibilityElement = true
requestButton.accessibilityLabel = "Request Button"
requestButton.accessibilityIdentifier = "test_button"
}
}
override func viewDidLoad() {
super.viewDidLoad()
dataDisclosureView.isAccessibilityElement = false
dataDisclosureView.accessibilityElements = [ descriptionView ?? "" ]
if #available(iOS 17.0, *) {
dataDisclosureView.automationElements = [ descriptionView ?? "",
requestButton ?? ""]
} else {
// Fallback on earlier versions
}
let requestButtonAction = UIAccessibilityCustomAction(name: "start",
target: self,
selector: #selector( request))
dataDisclosureView.accessibilityCustomActions = [ requestButtonAction ]
}
Mx issue is I want AccessibilityIdentifers for descriptionLabel,titleLabel,requestButton and hintLabel(For Automation) and accessibility labels for descriptionView and requestButton(VoiceOver Accessibility).
But I am unable to see accessibilityIdentifier for Button, TitleLabel and descriptionLabel in AccessibilityInspector. what am I doing wrong here?
I have an image and label inside UIStackView which are inside a viewcontroller. I want to make my UIView accessible. So I wrote below code:
var image: UIImage!
var myView: UIStackView!
var label : UILabel!
myView.isAccessibilityElement = true
myView.accessibilityLabel = "Hello"
myView.accessiblityIdentifier = "test_view"
image.accessiblityIdentifier = "test_image"
label.accessibilityIdentifier = "test_label"
All are UIKit Elements.
How to expose mvView to accessibility and only children to automation
I tried below two ways, none of them worked:
self.view.accessibilityElements = [myView]
myView.accessibilityElements = []
from apple documentation :
If the object is a view and it’s an accessibility element, and accessibilityElements is empty, the system assigns the list of subviews that have an accessibilityIdentifier to automationElements.
myView.automationElements = [myView,image,label]
from apple documentation :
In some cases, you might want to expose elements for automation but not for accessibility, or vice versa. In a view containing an image with a label under it, for example, you might choose to expose only the label for accessibility. For automation, however, you might include both the image and the label in a test to confirm the both objects exist. In this case, add both the image and the label to automationElements.
I am really going crazy with this since many days. Help is very much appreciated.
Is it a good idea to automate API calls used in my mobile APP in XCtests and check if response is in expected format. I want to test all the API calls used inside my app at one place rather than testing each feature which internally calls that API. This way I want to sure that my API's are working
I want to add my testing app and prod app for release in associated domain file. How can I add them in apple-app-site-association. Can I add both separated by coma
{
"webcredentials": {
"apps": [ "3ABCDEF.com.lalitha.release" , 3ABCDEF.com.lalitha.test]
}
}
In Apple documentation example they haven't mention about adding multiple apps under web credentials
[https://developer.apple.com/documentation/xcode/supporting-associated-domains]
I use this method to check Apple Event (Automation) permission:
bool checkAuth (string : appId)
{
OSStatus status = noErr;
if (@available(macOS 10.14, *)) {
NSAppleEventDescriptor *targetAppEventDescriptor;
targetAppEventDescriptor = [NSAppleEventDescriptor descriptorWithBundleIdentifier:appId.toNSString()];
status = AEDeterminePermissionToAutomateTarget(targetAppEventDescriptor.aeDesc, typeWildCard, typeWildCard, true);
}return status == noErr;
}
The problem is that the execution freezes once in 100 times at API: AEDeterminePermissionToAutomateTarget and the user is not prompted for authorization.
usage example:
checkSIPforAppIdentifier("com.microsoft.Word");
I have inserted necessary key in info.plist:
<key>NSAppleEventsUsageDescription</key>
<string>*** uses this feature to do do Typography actions.</string>
My App is not sandboxed.
PS: this issue is not consistently reproducible , once I restart the machine it works
How to distribute/install outlook add-ins for Mac programatically. From Microsoft documentation we are side loading add-in manually by adding the file or URL, wanted to know if there is any other way where I can distribute my add-in without user adding it manually
I followed this documentation https://www.adobe.com/content/dam/acom/en/devnet/acrobat/pdfs/plugin_apps_developer_guide.pdflooks like outdated. Is it possible to add adobe Reader Plugin. If yes where to start, which tool or language can be used to develop plugins.
Is there any API which takes bundle Identifier as input argument and returns if the application is installed in macOS
My requirement is to print a local file in mac OS to be printed from printer programtically. Any lead is much appreciated
Is there any framework in macOS to print a non pdf document. PDF kit is showing print panel that too only for PDF documents.Code snippet : let pdfView = PDFView() let path = URL(fileURLWithPath: "/Users/syamala/Desktop/Book1.pdf") let pdfDoc = PDFDocument(url: path) pdfView.document = pdfDoc let wnd = NSWindow() pdfView.autoScales = true pdfView.displaysPageBreaks = false wnd.setContentSize(pdfView.frame.size) wnd.contentView = pdfView pdfView.print(with: NSPrintInfo.shared, autoRotate: true)Shell command lp /Users/syamala/Desktop/Book1.pdf , even this prints only pdf docs but not non-pdf docs.Is there any swift native framework to print a document from local directory or shell command to print a document.
Below are the two ways i am doing it, but wanted to know which is best way to do it and whyFirst wayTimer.scheduledTimer(withTimeInterval: 43200, repeats: true) { timer in
let randomNumber = Int.random(in: 1...20)
print("Number: \(randomNumber)")
if randomNumber == 20 {
timer.invalidate()
}
}second waylet date = Date().addingTimeInterval(43200)
let timer = Timer(fireAt: date, interval: 0, target: self, selector: #selector(runCode), userInfo: nil, repeats: false)
RunLoop.main.add(timer, forMode: .common)
@objc func runCode()
{
print("Running code after every 5 seconds")
}
I can open multiple windows using a loop. Now I want to open these windows one by one. That means when I close one window the next window will be opened, I mean till the close of the first window next window should not be opened. Using below code all windows are getting opened at a time.let selectedFiles = ["file1","file2"]
for eachfile in selectedFiles
{
let storyBoard : NSStoryboard = NSStoryboard(name: "Main", bundle:nil)
let newViewController = storyBoard.instantiateController(withIdentifier: "MainView") as? ViewController
if newViewController != nil
{
newViewController.ParentView = self
self.presentAsModalWindow(newViewController!)
}
}I want the second window to open only after closing first window
I want to create shortcut of my application on desktop programatically and also add it to the docbar. At present i am doing it using bristow and emmet executables using shell script. I want to know is there any API in any of the frameworks that helps me to do using swift