iOS Developer Library

Developer

UIKit Framework Reference UIAccessibilityAction Protocol Reference

Options
Deployment Target:

On This Page
Language:

UIAccessibilityAction

The UIAccessibilityAction informal protocol provides a way for accessibility elements to support specific actions, such as selecting values in a range or scrolling through information on the screen. For example, to respond to a scrolling gesture, you implement the accessibilityScroll: method and post UIAccessibilityPageScrolledNotification with the new page status (such as “Page 3 of 9”). Or, to make an element such as a slider or picker view accessible, you first need to characterize it by including the UIAccessibilityTraitAdjustable trait. Then, you must implement the accessibilityIncrement and accessibilityDecrement methods. When you do this, assistive technology users can adjust the element using gestures specific to the assistive technology.

Inheritance


Not Applicable

Conforms To


Not Applicable

Import Statement


Swift

import UIKit

Objective-C

@import UIKit;

Availability


Available in iOS 4.0 and later.
  • Tells the element to activate itself and report the success or failure of the operation.

    Declaration

    Swift

    func accessibilityActivate() -> Bool

    Objective-C

    - (BOOL)accessibilityActivate

    Return Value

    YEStrue if the element was activated or NOfalse if it was not.

    Discussion

    You can use this method to make complex controls more readily accessible to users. The accessibility system calls this method when a VoiceOver user double taps the selected element. Your implementation of this method should activate the element and perform whatever other tasks it deems appropriate. For example, you might use the method to activate a control that requires a complex gesture and would be difficult for VoiceOver users to perform, possibly because the gesture has a different meaning when VoiceOver is running.

    After performing any tasks, return an appropriate Boolean value to indicate success or failure.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 7.0 and later.

  • Tells the accessibility element to increment the value of its content.

    Declaration

    Swift

    func accessibilityIncrement()

    Objective-C

    - (void)accessibilityIncrement

    Discussion

    If your element has the UIAccessibilityTraitAdjustable trait, you must implement this method. Use this method to increment the value of the element. For example, a UISlider object uses this method to increment its value by an appropriate amount.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 4.0 and later.

  • Tells the accessibility element to decrement the value of its content.

    Declaration

    Swift

    func accessibilityDecrement()

    Objective-C

    - (void)accessibilityDecrement

    Discussion

    If your element has the UIAccessibilityTraitAdjustable trait, you must implement this method. Use this method to decrement the value of the element. For example, a UISlider object uses this method to decrement its value by an appropriate amount.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 4.0 and later.

  • Scrolls screen content in an application-specific way and returns the success or failure of the action.

    Declaration

    Swift

    func accessibilityScroll(_ direction: UIAccessibilityScrollDirection) -> Bool

    Objective-C

    - (BOOL)accessibilityScroll:(UIAccessibilityScrollDirection)direction

    Parameters

    direction

    A constant that specifies the direction of the scrolling action. See UIAccessibilityScrollDirection for descriptions of valid constants.

    Return Value

    YEStrue if the scrolling action succeeds; otherwise, NOfalse. By default, this method returns NOfalse.

    Discussion

    Implement this method if a view in the view hierarchy supports a scroll by page action.

    • If the scrolling action succeeds for the specified direction, return YEStrue and post the UIAccessibilityPageScrolledNotification notification.

    • If the scrolling action fails, accessibilityScroll: is called on a parent view in the hierarchy.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 4.2 and later.

  • Dismisses a modal view and returns the success or failure of the action.

    Declaration

    Swift

    func accessibilityPerformEscape() -> Bool

    Objective-C

    - (BOOL)accessibilityPerformEscape

    Return Value

    YEStrue if the modal view is successfully dismissed; otherwise, NOfalse. By default, this method returns NOfalse.

    Discussion

    Implement this method on an element or containing view that can be revealed modally or in a hierarchy. When a VoiceOver user performs a dismiss action, this method dismisses the view. For example, you might implement this method for a popover in order to give users a deliberate dismiss action to perform that closes the popover.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 5.0 and later.

  • Performs a salient action.

    Declaration

    Swift

    func accessibilityPerformMagicTap() -> Bool

    Objective-C

    - (BOOL)accessibilityPerformMagicTap

    Return Value

    YEStrue if the magic tap action succeeds; otherwise, NOfalse. By default, this method returns NOfalse.

    Discussion

    The exact action performed by this method depends your app, typically toggling the most important state of the app. For example, in the Phone app it answers and ends phone calls, in the Music app it plays and pauses playback, in the Clock app it starts and stops a timer, and in the Camera app it takes a picture.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 6.0 and later.

  • An array of custom actions to display along with the built-in actions.

    Declaration

    Swift

    var accessibilityCustomActions: [AnyObject]!

    Objective-C

    @property(nonatomic, retain) NSArray *accessibilityCustomActions

    Discussion

    The array contains one or more UIAccessibilityCustomAction objects defining the supported actions. Assistive technologies such as VoiceOver display your custom actions to the user at appropriate times.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 8.0 and later.

Data Types

  • The direction of a scrolling action.

    Declaration

    Swift

    enum UIAccessibilityScrollDirection : Int { case Right case Left case Up case Down case Next case Previous }

    Objective-C

    typedef enum { UIAccessibilityScrollDirectionRight = 1, UIAccessibilityScrollDirectionLeft, UIAccessibilityScrollDirectionUp, UIAccessibilityScrollDirectionDown, UIAccessibilityScrollDirectionNext, UIAccessibilityScrollDirectionPrevious } UIAccessibilityScrollDirection;

    Constants

    • Right

      UIAccessibilityScrollDirectionRight

      The user is scrolling to the right.

      Available in iOS 4.2 and later.

    • Left

      UIAccessibilityScrollDirectionLeft

      The user is scrolling to the left.

      Available in iOS 4.2 and later.

    • Up

      UIAccessibilityScrollDirectionUp

      The user is scrolling up.

      Available in iOS 4.2 and later.

    • Down

      UIAccessibilityScrollDirectionDown

      The user is scrolling down.

      Available in iOS 4.2 and later.

    • Next

      UIAccessibilityScrollDirectionNext

      The user is scrolling to the next view in an ordered set of views.

      Available in iOS 5.0 and later.

    • Previous

      UIAccessibilityScrollDirectionPrevious

      The user is scrolling to the previous view in an ordered set of views.

      Available in iOS 5.0 and later.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 4.2 and later.