I am using this code but I dont know if it suits to you as the TableView events will not work (itemselect,accessorybuttonclick,...)
B4X:
Dim YourTableview as TableView
Dim no as NativeObject=YourTableView
no.setField("delegate",me)
Sub sc_begin(OffsetX As Int, OffsetY As Int)
'Begin Scrolling
End Sub
Sub sc_ScrollChanged (OffsetX As Int, OffsetY As Int)
'TableView is scrolling
End Sub
Sub sc_bottom
'Load More Data here
End Sub
#if OBJC
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
CGPoint offset = scrollView.contentOffset;
CGRect bounds = scrollView.bounds;
CGSize size = scrollView.contentSize;
UIEdgeInsets inset = scrollView.contentInset;
float y = offset.y + bounds.size.height - inset.bottom;
float h = size.height;
float reload_distance = 10;
if(y > h + reload_distance) {
NSLog(@"load more rows");
[self.bi raiseUIEvent:nil event:@"sc_bottom" params:@[]];
}
[self.bi raiseUIEvent:nil event:@"sc_scrollchanged::" params:@[@((float)scrollView.contentOffset.x),@((float)scrollView.contentOffset.y)]];
}
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView
{
[self.bi raiseUIEvent:nil event:@"sc_begin::" params:@[@((float)scrollView.contentOffset.x),@((float)scrollView.contentOffset.y)]];
}
#end if
I am using this code but I dont know if it suits to you as the TableView events will not work (itemselect,accessorybuttonclick,...)
B4X:
Dim YourTableview as TableView
Dim no as NativeObject=YourTableView
no.setField("delegate",me)
Sub sc_begin(OffsetX As Int, OffsetY As Int)
'Begin Scrolling
End Sub
Sub sc_ScrollChanged (OffsetX As Int, OffsetY As Int)
'TableView is scrolling
End Sub
Sub sc_bottom
'Load More Data here
End Sub
#if OBJC
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
CGPoint offset = scrollView.contentOffset;
CGRect bounds = scrollView.bounds;
CGSize size = scrollView.contentSize;
UIEdgeInsets inset = scrollView.contentInset;
float y = offset.y + bounds.size.height - inset.bottom;
float h = size.height;
float reload_distance = 10;
if(y > h + reload_distance) {
NSLog(@"load more rows");
[self.bi raiseUIEvent:nil event:@"sc_bottom" params:@[]];
}
[self.bi raiseUIEvent:nil event:@"sc_scrollchanged::" params:@[@((float)scrollView.contentOffset.x),@((float)scrollView.contentOffset.y)]];
}
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView
{
[self.bi raiseUIEvent:nil event:@"sc_begin::" params:@[@((float)scrollView.contentOffset.x),@((float)scrollView.contentOffset.y)]];
}
#end if
You can create a Boolean for example and when reloading new data set this Bollean to True and when finising the reload process set it to False. And for each sc_bottom event check if it is true or false. If it is true then Return