Forum Xamarin.Forms

NavigateUri does not seem to work in iOS - displays black text instead of a link.

Will.ItraxWill.Itrax CAMember ✭✭✭

Hi, In the Android project, in XAML, the code around NavigateUri displays a link to a web page in blue and underlined. When tapped, the browser opens the site. The code looks like:

<controls:HyperLinkLabel FontSize="20" HorizontalOptions="Start" NavigateUri="https://mypage.home.com/" Text="https://mypage.home.com/" VerticalOptions="Start" />

The same code when run on an iOS device just shows black text. However, when I tap that text, the app closes (not exactly what I want it to do).
Can someone enlighten me as to what is happening in iOS? Am I missing a special iOS setting?
Thanks!

Best Answer

Answers

  • TroyScarbroughTroyScarbrough USMember ✭✭

    realize I wont be of help to you but hopefully you could be of assistance. I am new to programming, coding etc . I have been using Xamarin Forms to help work on a phone app I am attempting to help build with a friend. I have come across numerous articles about web view but nothing really seems to help.

    Basically trying to figure out how to click on a button that would bring a website. Some sort of handle clicked event that takes user to another web page. Through googling I have seen this but when trying to use in XAML file mine does not take. Does it have to be changed from content page? Does something need to be declared for controls?

  • Will.ItraxWill.Itrax CAMember ✭✭✭

    I have moved away from XLabs and now display web pages by displaying a Label with an indicator of the web page (any text really) and the use a Gesture to trigger going to the url.

    In XAML:
    `

    <StackLayout Orientation="Vertical">
    
      <Label x:Name="label_Uri" 
       FontSize="20" 
      Text="{Binding URI_Desc}"  
      TextColor="DodgerBlue"
      VerticalOptions="Center" />
    </StackLayout>
    

    `

    In C#:
    `

                var tapGestureRecognizer = new TapGestureRecognizer();
                tapGestureRecognizer.Tapped += (s, e) => {
                    Device.OpenUri(new Uri(URI_ActualText));
                };
                label_Uri.GestureRecognizers.Add(tapGestureRecognizer);
    

    `

    (Sorry about the formatting)

Sign In or Register to comment.