Last active
December 14, 2015 11:38
-
-
Save maddievision/5080297 to your computer and use it in GitHub Desktop.
"thinking out loud" again.. a concept iOS Table View Controller in Python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
from NSFoundation import IndexPath | |
class TestTableViewController(UIKit.TableViewController): | |
def __init__(self): | |
super.__init__(self) | |
#do stuff | |
self.storage = [1,2,3,4,5] | |
self.title = "Test Data" | |
add_button = UIKit.BarButtonItem.system_button(UIKit.BAR_BUTTON_ADD_ITEM,handler=on_add_button) | |
self.navigation_item.right_bar_button_items = [add_button] | |
def on_add_button(self,sender): | |
self.storage.append(0) | |
self.table_view.insert_row(IndexPath(row=len(self.storage)-1,section=0),animated=True) | |
def section_count(self,table_view): | |
return 0 | |
def row_count(self,table_view,section): | |
return len(self.storage) | |
def section_title(self,table_view,section): | |
return "Stuff" | |
def cell(self,table_view,index_path): | |
cell = self.deque_cell(reuse_identifier="Cell") | |
if not cell: | |
cell = UIKit.TableViewCell(style=UIKit.TABLE_VIEW_CELL_STYLE_VALUE1) | |
cell.textLabel.text = "A cell" | |
cell.detailTextLabel.text = str(self.storage[index_path.row]) | |
def on_cell_select(self,table_view,index_path): | |
UIKit.show_alert(title="Selected",message="You selected cell %d" % index_path.row) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment