Pull To Refresh on UIScrollView

MarthughieMarthughie GBMember ✭✭
edited July 2015 in Xamarin.iOS

I have a UIScrollView within a UIViewController within a UITabBarController

I want to be able to let the user refresh the data in the UIScrollView (ideally by pulling on the control).

I have looked at using a UIRefreshControl, but note that these can only be used within UITableViewControllers.

What are my options ?

Thanks

Posts

  • ArturMalendowiczArturMalendowicz USMember ✭✭
    var scroll = new UIScrollView(new CGRect(0, 64, this.View.Frame.Width, this.View.Frame.Height));
    
            scroll.UserInteractionEnabled = true;
            scroll.ShowsHorizontalScrollIndicator = false;
            scroll.ShowsVerticalScrollIndicator = false;
            scroll.BackgroundColor = UIColor.White;
            scroll.ContentSize = new CGSize(this.View.Frame.Width, 1000);
    
            var refresh = new UIRefreshControl();
            scroll.AddSubview(refresh);
            this.View.Add(scroll);
    
  • MarthughieMarthughie GBMember ✭✭

    @ArturMalendowicz many thanks for this, I can see refresh user feedback from your code.

    It does not yet work with my code I need to dig a little deeper to find out why. One difference is that my scrollview has multiple UIViews in/on it and each of those contains a UITextview - so perhaps I should not expect to see the refresh wheel. Will investigate and find out what the problem is. Thanks again.

  • ArturMalendowiczArturMalendowicz USMember ✭✭

    Have you set UserInteractionEnabled to true and are you sure ContenSize is greater than screen size?

  • MartHughMartHugh USMember ✭✭✭

    Yes to the first, and for the second, the content size is wider than the screen width (10x), but not taller. I need to scroll panes left and right and don't want them to move vertically during normal scrolling.

Sign In or Register to comment.