Created
June 24, 2014 19:09
-
-
Save topgenorth/654088b79b15a729f070 to your computer and use it in GitHub Desktop.
Set the accessibility Id
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class UIViewHelpers | |
{ | |
static readonly IntPtr selAccessibilityIdentifier_Handle = Selector.GetHandle("accessibilityIdentifier"); | |
static readonly IntPtr setAccessibilityIdentifier_Handle = Selector.GetHandle("setAccessibilityIdentifier:"); | |
public static UIView SetAccessibilityId(this UIView view, string id) | |
{ | |
var intPtr = NSString.CreateNative(id); | |
Messaging.void_objc_msgSend_IntPtr(view.Handle, setAccessibilityIdentifier_Handle, intPtr); | |
NSString.ReleaseNative(intPtr); | |
return view; | |
} | |
public static string GetAccessibilityId(this UIView view) | |
{ | |
return NSString.FromHandle(Messaging.IntPtr_objc_msgSend(view.Handle, selAccessibilityIdentifier_Handle)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment