Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Extra header row added to tableview when I add subviews to the cells.
-
Heres a code sample. If you comment out the three lines creating and adding the label the view looks fine. I need to add subviews because I'm trying to create a grid-style table of labels and values.
import ui class MyTableViewDataSource (object): def tableview_number_of_sections(self, tableview): # Return the number of sections (defaults to 1) return 1 def tableview_number_of_rows(self, tableview, section): # Return the number of rows in the section return 3 def tableview_cell_for_row(self, tableview, section, row): # Create and return a cell for the given section/row cell = ui.TableViewCell() #cell.text_label.text = 'Foo Bar' # uncomment to switch behaviours label = ui.Label() # comment out to switch behaviour label.text = 'mylabel' # comment out to switch behaviour cell.add_subview(label) # comment out to switch behaviour return cell data_source = MyTableViewDataSource() tv = ui.TableView() tv.data_source = data_source mv = ui.View() mv.add_subview(tv) mv.present()
-
There isn't really any extra header view, your label frames are just incorrect for some reason and overlap with the next cell (not quite sure why right now)... Try adding something like
label.frame = cell.bounds
before you add the label to the cell. -
That does the trick in the example. I can't use it directly in the real code because I'm putting several labels into the cell, but it should just be a matter of calculating the required frame geometries for the labels. Thanks!
- update. The workaround works fine for my use case. I set the label frame to the cell bounds, then offset .x and .width as required. Looks perfect!