DavinE
Jan 08, 2022 - 16:32
Hello,
Is it possible to use an external button to tell the TableView to jump to row x ?
Hello,
Is it possible to use an external button to tell the TableView to jump to row x ?
@DavinE try, in ObjectiveC
NSIndexPath = ObjCClass("NSIndexPath")
nsindex = NSIndexPath.indexPathForRow_inSection_(row,0 )
UITableViewScrollPosition = 0 #None
# 1 Top
# 2 Middle
# 3 Bottom
ObjCInstance(your_tableview).scrollToRowAtIndexPath_atScrollPosition_animated_(nsindex, UITableViewScrollPosition, True)
Or, in Python, set tableview.content_offset to right x,y position
@DavinE try
import ui
from objc_util import *
class source (object):
def tableview_number_of_rows(self, tv, s):
return 100
def tableview_cell_for_row(self, tv, s, r):
cell = ui.TableViewCell('0')
cell.text_label.text = str(r)
return cell
view = ui.TableView()
view.data_source = source()
b = ui.ButtonItem()
b.title = 'row 40'
row= 40
def b_action(sender):
NSIndexPath = ObjCClass("NSIndexPath")
nsindex = NSIndexPath.indexPathForRow_inSection_(row,0 )
UITableViewScrollPosition = 1
# 1 Top
# 2 Middle
# 3 Bottom
ObjCInstance(view).scrollToRowAtIndexPath_atScrollPosition_animated_(nsindex, UITableViewScrollPosition, True)
b.action = b_action
view.right_button_items = [b,]
view.present()
@DavinE is it what you asked?
@cvp
Yes, I'm just not so fast with the implement xD
it works perfectly thank you for your quick help!