Forum Xamarin.Forms

MasterPage always detected by IOS VoiceOver into DetailPages

Liuk88Liuk88 ITMember ✭✭✭

Hello guys, I'm trying to make my application accessible.
I have a Master-Detail layout for my pages and I have the following problem:
In all Detail pages the MasterPage is read from VoiceOver, even if the menu is closed (and the Master page is not showed).
How can I solve in order fix this?
Thanks a lot

Answers

  • TaylorDTaylorD USMember ✭✭✭

    I encountered this same issue on iOS and found a fix somewhere on the Forums or StackOverflow. Here is the solution. Also, a different renderer is needed for both iPhone and Tablet.

    PhoneRenderer

    public class PhoneDefaultMasterDetailRenderer : PhoneMasterDetailRenderer
    {
        public override void ViewWillLayoutSubviews()
        {
            base.ViewWillLayoutSubviews();
    
            if (Element is MasterDetailPage item)
            {
                var master = NativeView.Subviews[0];
    
                if (item.IsPresented)
                {
                    master.AccessibilityElementsHidden = false;
                }
                else
                {
                    master.AccessibilityElementsHidden = true;
                }
    
               NativeView.SetNeedsFocusUpdate();
            }
        }
    }
    

    TabletRenderer

    public class TabletDefaultMasterDetailRenderer : TabletMasterDetailRenderer
    {
        public override void ViewWillLayoutSubviews()
        {
            base.ViewWillLayoutSubviews();
    
            if (Element is MasterDetailPage item)
            {
                var master = NativeView.Subviews[0];
    
                if (item.IsPresented)
                {
                    master.AccessibilityElementsHidden = false;
                }
                else
                {
                    master.AccessibilityElementsHidden = true;
                }
    
                NativeView.SetNeedsFocusUpdate();
            }
        }
    }
    
  • Liuk88Liuk88 ITMember ✭✭✭

    Hi Taylor, I noticed that sometimes I have the same problem on Android, can I achieve the same in CrossPlatform way? For example setting something inside my MasterDetailPage? If possible, I prefer to avoid custom renderer since I have no experience on them
    Thanks

  • TaylorDTaylorD USMember ✭✭✭

    I haven't found the issue on Android in my experiences so I don't have a solution for that. I'm also not sure of a CrossPlatform way to achieve this due to it being an issue with a lower subview in iOS.

  • DanielHJDanielHJ Member ✭✭
    edited March 2020

    Sorry, I am quite new with Xamarin.

    How would I implement this in the app?
    Do I just have have to create a file with the code inside the iOS target of the project, or is there something else I need to do?

    Edit:

    Never mind, I solved it :)

Sign In or Register to comment.