iOS Tutorial Add UIRefreshControl To CustomListView

Original Tutorial by @narek adonts

Create a standard class module (Let assume the name of the class is UIRefreshControl),
Sub Class_Globals
    Private CSB As CSBuilder
    Private cb As Object
    Private en As String
    Private RefreshControl As NativeObject
End Sub

Public Sub Initialize(callback As Object, EventName As String, sv As ScrollView)
    cb = callback
    Dim no As NativeObject=Me
    RefreshControl = no.RunMethod("AddRefresh:",Array(sv))
    RefreshControl.SetField("attributedTitle",CSB.Initialize.Append("Pull to refresh").PopAll) 'You can add AttributedString
End Sub

Public Sub EndRefreshing
    RefreshControl.SetField("attributedTitle",CSB.Initialize.Append("Pull to refresh").PopAll) 'You can add AttributedString
End Sub

Private Sub RC_Refresh(RC As Object)
    RefreshControl.SetField("attributedTitle",CSB.Initialize.Append("Refreshing...").PopAll) 'You can add AttributedString
    CallSub(cb, en&"_PullRefresh")
End Sub

-(UIRefreshControl *)AddRefresh: (UIScrollView*)scrollView {
    UIRefreshControl *refreshControl = [[UIRefreshControl alloc] init];
    [scrollView addSubview:refreshControl];
    [refreshControl addTarget:self action:@selector(refresh:) forControlEvents:UIControlEventValueChanged];
    return refreshControl;

- (void)refresh:(id)sender {
    UIRefreshControl *refreshControl=sender;
    [ raiseEvent:nil event:@"rc_refresh:" params:@[(refreshControl)]];

#end if

Now you can use this class to add refresh control to any CLV of any page you want. like this,
'Code module

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'Public variables can be accessed from all modules.
    Public MainPage As Page
    Private MainPageScroll As CustomListView
    Private MainRC As UIRefreshControl
End Sub

Public Sub ShowModule

    MainRC.Initialize(Me,"MainPageScroll", 'add refresh control to CLV scrollview
End Sub

Sub MainPageScroll_PullRefresh
    Sleep(3000) 'do whatever you want
End Sub

Happy Coding :)
Last edited:

Active Member
Licensed User
There is a bad problem
When I have only two items in CLV, the refreshcontrol not working
I understood when clv inner panel height is lower than clv height, refreshcontrol not working
I try to add the fake items to CLV and good working but that is not a good solution
Can I change the default inner panel height to max value?

Active Member
Licensed User
My problem was solved
Use below code:
    sv.Bounces = True
    Dim no As NativeObject = sv
    no.RunMethod("setAlwaysBounceVertical:", Array(True))

Active Member
Licensed User
Also you can change activityindicator color with below code:
Dim no As NativeObject = RefreshControl
 no.RunMethod("setTintColor:", Array(x.ColorToUIColor(Color)))