iOS Question PullToRefresh CustomListView for B4i

Keith Yong

Active Member
Licensed User
Longtime User
Upvote 0

narek adonts

Well-Known Member
Licensed User
Longtime User
Base on your reference, I try to change to CustomListView but it seems doesn't work.

Public Sub AddRefresh (clView As CustomListView)
Dim nome asNativeObject=Me
nome.RunMethod("AddRefresh:",Array(clView))
End Sub


That was for TableView.

Try this for Scrollview

B4X:
Public Sub AddRefresh (ScrollView as ScrollView)
Dim nome as NativeObject=Me  
nome.RunMethod("AddRefresh:",Array(ScrollView))
End Sub

Sub refreshing(RefreshControl As Object)
  
      ' DO YOUR REFRESHING JOB

    Dim no As NativeObject=RefreshControl
    no.RunMethod("endRefreshing",Null)  ' END REFRESHING
End Sub

#IF OBJC

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

- (void)refresh:(id)sender {
 
    UIRefreshControl *refreshControl=sender;
    [self.bi raiseEvent:nil event:@"refreshing:" params:@[(refreshControl)]];
  
}

#END IF
 
Upvote 0

Keith Yong

Active Member
Licensed User
Longtime User
That was for TableView.

Try this for Scrollview

B4X:
Public Sub AddRefresh (ScrollView as ScrollView)
Dim nome as NativeObject=Me 
nome.RunMethod("AddRefresh:",Array(ScrollView))
End Sub

Sub refreshing(RefreshControl As Object)
 
      ' DO YOUR REFRESHING JOB

    Dim no As NativeObject=RefreshControl
    no.RunMethod("endRefreshing",Null)  ' END REFRESHING
End Sub

#IF OBJC

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

- (void)refresh:(id)sender {

    UIRefreshControl *refreshControl=sender;
    [self.bi raiseEvent:nil event:@"refreshing:" params:@[(refreshControl)]];
 
}

#END IF

it still not working, do I need to put this routine under the CustomListView module class?
 
Upvote 0

Keith Yong

Active Member
Licensed User
Longtime User
Are you passong the scrollView of clv as paramter?

what error are you getting?
I get this error


Application_Start
Error occurred on line: 46 (Main)
Expected: UIScrollView, object type: b4i_customlistview
Stack Trace: (
CoreFoundation __exceptionPreprocess + 180
libobjc.A.dylib objc_exception_throw + 50
CoreFoundation +[NSException raise:format:] + 141
Json -[B4IObjectWrapper setObject:] + 298
Json +[B4IObjectWrapper createWrapper:eek:bject:] + 117
Json -[B4IRDebugUtils ConvertToWrapper::] + 63
CoreFoundation __invoking___ + 29
CoreFoundation -[NSInvocation invoke] + 342
Json +[B4I runDynamicMethod:method:throwErrorIfMissing:args:] + 2069
Json -[B4IShell runMethod:] + 515
Json -[B4IShell raiseEventImpl:method:args::] + 1888
Json -[B4IShellBI raiseEvent:event:params:] + 1623
Json __33-[B4I raiseUIEvent:event:params:]_block_invoke + 67
libdispatch.dylib _dispatch_call_block_and_release + 15
libdispatch.dylib _dispatch_client_callout + 14
libdispatch.dylib _dispatch_main_queue_callback_4CF + 689
CoreFoundation __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 14
CoreFoundation __CFRunLoopRun + 2356
CoreFoundation CFRunLoopRunSpecific + 470
CoreFoundation CFRunLoopRunInMode + 123
GraphicsServices GSEventRunModal + 192
GraphicsServices GSEventRun + 104
UIKit UIApplicationMain + 160
Json main + 138
libdyld.dylib start + 1
)
Application_Active
 
Upvote 0

narek adonts

Well-Known Member
Licensed User
Longtime User
Upvote 0

Keith Yong

Active Member
Licensed User
Longtime User
you should pass the scrollview not the customlistview.

In CustomListView class change Private sv As ScrollView to Public sv as Scrollview and after that you can pass clv.sv as parameter
Done, but this time getting this error

Method not found: AddRefresh:, target: <b4i_main: (null)>
 
Upvote 0

Lucas Siqueira

Active Member
Licensed User
Longtime User
Do you have a working example on this feature?
Thanks
FBP


Hello Friend!

Here is an example, I also suffered to discover the error!

you have Skype?
 

Attachments

  • b4i - CustomListView10em10.zip
    9.3 KB · Views: 238
Upvote 0
Top