C# 使用UIView.AccessibilityValue或AccessibilityIdentifier属性在ios xamarin中存储某些自定义数据是否正确?

C# 使用UIView.AccessibilityValue或AccessibilityIdentifier属性在ios xamarin中存储某些自定义数据是否正确?,c#,ios,iphone,uiview,xamarin.ios,C#,Ios,Iphone,Uiview,Xamarin.ios,我的问题是 1) 我是否可以使用 AccessibilityValue/AccessibilityIdentifier属性来标识或 跟踪控件(子视图)。(在子视图中循环并查找 具有AccessibilityValue/Identifier的特定控件) 2) 当我将这些属性设置为某个值时,这些 值与任何系统生成的值(如果有)冲突 3) 我可以用它们来存储一些数据吗?比如说,如果我想显示一个列表 用户数量(将用户id存储在 子视图),在滚动视图中显示(不使用表视图 显示它们) 4) 最后但并非最不

我的问题是

  • 1) 我是否可以使用 AccessibilityValue/AccessibilityIdentifier属性来标识或 跟踪控件(子视图)。(在子视图中循环并查找 具有AccessibilityValue/Identifier的特定控件)
  • 2) 当我将这些属性设置为某个值时,这些 值与任何系统生成的值(如果有)冲突
  • 3) 我可以用它们来存储一些数据吗?比如说,如果我想显示一个列表 用户数量(将用户id存储在 子视图),在滚动视图中显示(不使用表视图 显示它们)
  • 4) 最后但并非最不重要的一点是,做1中的事情是一个好的实践吗 和3使用这些属性
这里的代码段仅供参考

    private void GenerateUI(){
       UIView containerView = new UIView( new RectangleF(0,0,View.Frame.Width,View.Frame.Height));
       View.AddSubview(containerView);

       var leaderBoardButton = new UIButton(UIButtonType.System);
                leaderBoardButton.Frame = new RectangleF(0, 200, 220, 40);
                leaderBoardButton.Layer.BorderColor = UIColor.White.CGColor;
                leaderBoardButton.Layer.BorderWidth = 0.5f;
                leaderBoardButton.Layer.BorderColor = UIColor.White.ColorWithAlpha (0.6f).CGColor;
                leaderBoardButton.BackgroundColor = UIColor.Clear;
                leaderBoardButton.SetTitle("Leaderboard", UIControlState.Normal);
                leaderBoardButton.SetTitleColor (UIColor.White, UIControlState.Normal);
                leaderBoardButton.AccessibilityValue= "leaderboardButton";
                leaderBoardButton.TouchUpInside += (sender, e) => {
                    somefunction();
                };

      containerView.Add(leaderBoardButton)


       var communityButton = new UIButton(UIButtonType.System);
                communityButton.Frame = new RectangleF(0, 240, 220, 40);
                communityButton.Layer.BorderColor = UIColor.White.ColorWithAlpha (0.6f).CGColor;
                communityButton.Layer.BorderWidth = 0.5f;
                communityButton.BackgroundColor = UIColor.Clear;
                communityButton.SetTitle("Community", UIControlState.Normal);
                communityButton.SetTitleColor (UIColor.White, UIControlState.Normal);
                communityButton.AccessibilityValue= "communityButton";
                communityButton.TouchUpInside += (sender, e) => {
                    //VirtualMentorDemo2ViewController vdc = (UIApplication.SharedApplication.Delegate as   AppDelegate).StoryBoard.InstantiateViewController("VirtualMentorDemo2ViewController") as VirtualMentorDemo2ViewController;
                    //NavController.PushViewController(vdc, false);
                    //SidebarController.CloseMenu();
                };

    containerView.Add(communityButton);


    }

使用可访问性属性来存储额外的元数据不是一个好主意。可访问性系统使用这些功能向可能已打开它的用户提供信息


如果要标记项目,可以在UIView中使用“tag”属性进行标记。

能否详细解释前两行。基本上,无障碍系统如何以及何时访问它并使用这些道具?