Sha256: a49d1267f19cf1af37a5f3c2dffa3e2edc61836b78cbbd8806a74b03dbf17c9a

Contents?: true

Size: 684 Bytes

Versions: 18

Compression:

Stored size: 684 Bytes

Contents

# To make accessibility labels work in UIActionSheets
# adapted from https://gist.github.com/953326

class UIActionSheet

  alias_method :old_addButtonWithTitle, :addButtonWithTitle

  def addButtonWithTitle(title)
    button_index = old_addButtonWithTitle(title)
    self.subviews.each { |subview|
      if subview.respond_to? :title
        controlTitle = subview.send(:title)
        if (title == controlTitle)
          copyAccessibilityMetadataFrom(title, toControl: subview)
          return button_index
        end
      end
    }
    button_index
  end

  private
  def copyAccessibilityMetadataFrom(title, toControl:control)
    control.accessibilityLabel = title
  end

end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
formotion-1.8 lib/formotion/patch/ui_action_sheet.rb
formotion-1.7 lib/formotion/patch/ui_action_sheet.rb
formotion-1.6 lib/formotion/patch/ui_action_sheet.rb
formotion-1.5.1 lib/formotion/patch/ui_action_sheet.rb
formotion-1.5.0 lib/formotion/patch/ui_action_sheet.rb
formotion-1.4.0 lib/formotion/patch/ui_action_sheet.rb
formotion-1.3.1 lib/formotion/patch/ui_action_sheet.rb
formotion-1.3 lib/formotion/patch/ui_action_sheet.rb
formotion-1.2 lib/formotion/patch/ui_action_sheet.rb
formotion-1.1.5 lib/formotion/patch/ui_action_sheet.rb
formotion-1.1.4 lib/formotion/patch/ui_action_sheet.rb
formotion-1.1.3 lib/formotion/patch/ui_action_sheet.rb
formotion-1.1.2 lib/formotion/patch/ui_action_sheet.rb
formotion-1.1.1 lib/formotion/patch/ui_action_sheet.rb
formotion-1.1 lib/formotion/patch/ui_action_sheet.rb
formotion-1.0 lib/formotion/patch/ui_action_sheet.rb
formotion-0.5.1 lib/formotion/patch/ui_action_sheet.rb
formotion-0.5 lib/formotion/patch/ui_action_sheet.rb