Hey Guys,
I need help with my Issue..
My tableview works fine for me but only with the reload function....
i don't get it to work with the insert_rows function....
i Hope anyone can help me ;)
and sry for my bad English :(
Thats my Code:
import ui
def test1(tableview, section, row):
print(tableview.data_source.items)
tableview.data_source.items[row][1] = '+110'
print(tableview.data_source.items)
tableview.reload_data()
#tableview.insert_rows([row])
print('TEST')
print(tableview.data_source.items)
def tableview_number_of_rows(tableview, section):
print(len(tableview.data_source.items))
return len(tableview.data_source.items)
def tableview_cell_for_row(tableview, section, row):
cell =ui.TableViewCell("subtitle")
data_textLabel = tableview.data_source.items[row][0]
data_detailTextLable = tableview.data_source.items[row][1]
cell.bg_color = '#98FB98' if data_detailTextLable[0] == '+' else '#F08080'
cell.accessory_type = 'detail_button'
cell.selectable = False
cell.text_label.text = str(data_textLabel)
cell.detail_text_label.text = str(data_detailTextLable)
try:
# iPhone 24 iPad 32
cell.image_view.image = ui.Image.named('iob:clipboard_24')
except AttributeError:
pass
return cell
v = ui.View()
f = (0, 0, 600, 800)
v.frame = f
tbl = ui.TableView()
tbl.frame = f
datasource = [['0002', '+9'], ['0001', '+18'], ['0002', '-1']]
tbl.data_source = ui.ListDataSource(items=datasource)
tbl.data_source.tableview_cell_for_row = tableview_cell_for_row
tbl.data_source.tableview_number_of_rows = tableview_number_of_rows
tbl.delegate = tbl.data_source.tableview_cell_for_row
tbl.delegate.tableview_accessory_button_tapped = test1
v.add_subview(tbl)
v.present('sheet')
print(tbl.data_source.items)