Pull to Refresh works in Android, but it doesn't do anything in iOS

BillyMartinBillyMartin USMember ✭✭
edited November 8 in Xamarin.Forms

In Xamarin PCL, I have no problem with the Pull to Refresh in my Androidproject, but when I launch iOS using Visual Studio 2017 for windows and a Mac mini, it's as if it weren't even there. The regular listview pull to refresh does work in my iOS, though. Are there differences? Here is the xaml:

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="HunterTracker.Pages.LunarPhases"
             xmlns:controls="clr-namespace:Refractored.XamForms.PullToRefresh;assembly=Refractored.XamForms.PullToRefresh"
            Title="Lunar"
             xmlns:control2="clr-namespace:HunterTracker.Controls;assembly=HunterTracker"
             BackgroundImage="camouflagetexture.jpg">

    <ContentPage.Resources>
        <ResourceDictionary>
            <Style x:Key="labelStyle" TargetType="Label">
                <Setter Property="TextColor" Value="White" />
                <Setter Property="FontSize" Value="Large" />
            </Style>
            <Style x:Key="fieldStyle" TargetType="Label">
                <Setter Property="TextColor" Value="White" />
                <Setter Property="FontSize" Value="Medium" />
            </Style>
            <Style x:Key="fieldView" TargetType="ContentView">
                <Setter Property="Padding" Value="0" />
            </Style>
        </ResourceDictionary>
    </ContentPage.Resources>

    <ContentPage.Content>

        <StackLayout Padding="0" Margin="0">

            <controls:PullToRefreshLayout
            IsPullToRefreshEnabled="true"
            RefreshCommand="{Binding GetLunarCommand}"
            IsRefreshing="{Binding IsBusy}"
            RefreshColor="White"
            RefreshBackgroundColor="DarkOliveGreen" >

                <ScrollView>
                    <StackLayout Margin="0" Padding="0">
                            <Label Text="Pull Down To Refresh"  HorizontalOptions="Center" Margin="5" TextColor="White"/>

                        <!-- Weather Display Bindings -->
                        <StackLayout Orientation="Horizontal" Margin="20,20, 5, 0">
                            <StackLayout HorizontalOptions="Start">
                                <Label Text="Sunrise:" Style="{StaticResource fieldStyle}" />
                                <ContentView Style="{StaticResource fieldView}">
                                    <Label Text="{Binding Sunrise}" Style="{StaticResource fieldStyle}" />
                                </ContentView>
                                <Label Text="Sunset:" Style="{StaticResource fieldStyle}" />
                                <ContentView Style="{StaticResource fieldView}">
                                    <Label x:Name="sunsetLabel" Text="{Binding Sunset}" Style="{StaticResource fieldStyle}" />
                                </ContentView>

                                <Label Text="Moonrise:" Style="{StaticResource fieldStyle}" />
                                <ContentView Style="{StaticResource fieldView}">
                                    <Label x:Name="moonriseLabel" Text="{Binding Moonrise}" Style="{StaticResource fieldStyle}" />
                                </ContentView>
                            </StackLayout>

                            <StackLayout>
                                <Image x:Name="MoonImage" VerticalOptions="Start" Source="{Binding MoonImage}"/>

                            </StackLayout>
                        </StackLayout>


                        <StackLayout Orientation="Horizontal" Margin="20, 0">
                            <StackLayout HorizontalOptions="StartAndExpand">
                            <Label Text="Overhead:" Style="{StaticResource fieldStyle}" />
                        <ContentView Style="{StaticResource fieldView}">
                            <Label x:Name="moonOverheadLabel" Text="{Binding MoonOverhead}" Style="{StaticResource fieldStyle}" />
                        </ContentView>

                        <Label Text="Moonset:" Style="{StaticResource fieldStyle}" />
                        <ContentView Style="{StaticResource fieldView}">
                            <Label x:Name="moonsetLabel" Text="{Binding Moonset}" Style="{StaticResource fieldStyle}" />
                        </ContentView>


                            </StackLayout>
                            <StackLayout HorizontalOptions="EndAndExpand">
                                <ContentView Style="{StaticResource fieldView}">
                                    <Label x:Name="moonphaselabel" Text="{Binding Moonphase}" 
                                           Style="{StaticResource fieldStyle}" />
                                </ContentView>

                                <ContentView Style="{StaticResource fieldView}">
                                    <Label x:Name="illuminationLabel" Text="{Binding Illumination}" 
                                           Style="{StaticResource fieldStyle}" />
                                </ContentView>
                            </StackLayout>
                        </StackLayout>
                        <ContentView Style="{StaticResource fieldView}">
                            <Label x:Name="dayLengthLabel" Text="{Binding DayLength}"
                                   Style="{StaticResource fieldStyle}" HorizontalOptions="Center"/>
                        </ContentView>
                    </StackLayout>
                </ScrollView>


            </controls:PullToRefreshLayout>
            <StackLayout Padding="0" Margin="0" VerticalOptions="EndAndExpand">
                <control2:AdControlView Margin="0"/>
            </StackLayout>
        </StackLayout>
    </ContentPage.Content>

</ContentPage>

Best Answer

  • BillyMartinBillyMartin USMember ✭✭
    Accepted Answer

    Your last suggestion sparked an idea. I didn't have this code in my AppDelegate:

    PullToRefreshLayoutRenderer.Init();

    Works fine now! Thanks for your time.

Answers

  • RasmusVindRasmusVind USMember ✭✭
    edited November 9

    Its properly a problem with the ScrollView.
    i had the same, pull working on andoid and not on iOS. had to remove the scrollview to get it to work.

    The worst thing is that i cant say what is causing it, i have one page where it works and one where i have to remove the scrollview....

  • BillyMartinBillyMartin USMember ✭✭

    Thanks for the advice. I will try it, but how do I get it to scroll without the scrollview? The page is too long.

  • BillyMartinBillyMartin USMember ✭✭

    I tried it without scrollview and it still wouldn't work. Thanks for the suggestion, though!

  • JosephHarveyJosephHarvey USMember

    could you post your custom Renderer?
    <controls:PullToRefreshLayout

  • BillyMartinBillyMartin USMember ✭✭
    edited November 10

    I'm using Motz's plugin. No custom renderer that I know of.

    Here's his github:

    https://github.com/jamesmontemagno/Xamarin.Forms-PullToRefreshLayout

  • BillyMartinBillyMartin USMember ✭✭
    Accepted Answer

    Your last suggestion sparked an idea. I didn't have this code in my AppDelegate:

    PullToRefreshLayoutRenderer.Init();

    Works fine now! Thanks for your time.

Sign In or Register to comment.