Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
414 views
in Technique[技术] by (71.8m points)

iphone - iOS change accessibility focus.

is there a way to set the accessibility focus programatically (App Store-safe)? Any help will be greatly appreciated.

question from:https://stackoverflow.com/questions/7529464/ios-change-accessibility-focus

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

To focus on element you can call.

Swift:

UIAccessibility.post(notification: .screenChanged, argument: self.myFirstView)

ObjC:

UIAccessibilityPostNotification(UIAccessibilityScreenChangedNotification, self.myFirstView);

Otherwise for iOS 8+ use the accessibilityElements to set element order and it will focus automatically on first element in the list

self.accessibilityElements = @[myFirstView, mySecondButton, myThirdLabel]

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...