UITableView
, works only with simple children viewsios :: TableView :: cell_for_row_at_index_path
Return aUITableViewCell
for the item at index_path
ios :: TableView :: defaultinit
ios :: TableView :: number_of_rows_in_section
Number of entries insection
ios :: TableView :: number_of_sections_in_table_view
Number of sections in this viewios :: TableView :: title_for_header_in_section
Title forsection
, return new NSString.nil
for no title
native
implementation of this control
ios :: TableView :: cell_for_row_at_index_path
Return aUITableViewCell
for the item at index_path
core :: Object :: class_factory
Implementation used byget_class
to create the specific class.
ios :: TableView :: defaultinit
gtk :: GtkCallable :: defaultinit
core :: Finalizable :: defaultinit
app :: CompositeControl :: defaultinit
app :: AppObserver :: defaultinit
app :: Control :: defaultinit
app :: AppComponent :: defaultinit
core :: Object :: defaultinit
core :: Finalizable :: finalize
Liberate any resources held byself
before the memory holding self
is freed
core :: Object :: is_same_instance
Return true ifself
and other
are the same instance (i.e. same identity).
core :: Object :: is_same_serialized
Isself
the same as other
in a serialization context?
core :: Object :: is_same_type
Return true ifself
and other
have the same dynamic type.
app :: AppComponent :: notify_observers
Propagateevent
to all observers
by calling AppObserver::on_event
ios :: TableView :: number_of_rows_in_section
Number of entries insection
ios :: TableView :: number_of_sections_in_table_view
Number of sections in this viewapp :: AppComponent :: observers
AllAppObserver
notified of events raised by self
app :: AppComponent :: observers=
AllAppObserver
notified of events raised by self
app :: AppComponent :: on_pause
The application leaves the active state but is still partially visibleapp :: AppComponent :: on_restart
The application returns to a visible state from a previouson_stop
app :: AppComponent :: on_restore_state
The application is launching, restore its state from a previouson_save_state
app :: AppComponent :: on_resume
The application enters the active state, it is in the foreground and interactiveapp :: AppComponent :: on_save_state
The application may be destroyed soon, save its state for a futureon_restore_state
app :: AppComponent :: on_start
The application is starting or restarting, it is visible to the usercore :: Object :: output_class_name
Display class name on stdout (debug only).Control
in the control tree
Control
in the control tree
ios :: TableView :: title_for_header_in_section
Title forsection
, return new NSString.nil
for no title
app :: AppComponent
An element of an application that is notified of the application life cyclegtk :: GtkCallable
# iOS specific layout using a `UITableView`, works only with simple children views
class TableView
super CompositeControl
redef type NATIVE: UITableView
redef var native = new UITableView(new UITableViewStyle.plain)
init
do
native.autoresizing_mask
native.assign_delegate_and_data_source self
end
redef fun add(item)
do
# Adding a view to a UITableView is a bit tricky.
#
# Items are added to the Objective-C view only by callbacks.
# We must store the sub views in local lists while waiting
# for the callbacks.
#
# As usual, we keep the Nity object in `items`.
# But we also keep their native counterparts in a list of
# the `UITableViewAndDataSource` set as `native.delegate`.
# Otherwise the native views could be freed by the Objective-C GC.
# TODO use an adapter for the app.nit ListLayout closer to what exists
# on both iOS and Android, to support large data sets.
if item isa View then
add_view_to_native_list(native, item.native)
end
super
# Force redraw and trigger callbacks
native.reload_data
end
private fun add_view_to_native_list(native: UITableView, item: UIView) in "ObjC" `{
[((UITableViewAndDataSource*)native.delegate).views addObject:item];
`}
private fun get_view_from_native_list(native: UITableView, index: Int): UIView in "ObjC" `{
return [((UITableViewAndDataSource*)native.delegate).views objectAtIndex:index];
`}
# Number of sections in this view
#
# By default, we assume that all `items` are in a single section,
# so there is only one section.
#
# iOS callback: `numberOfSectionsInTableView`
protected fun number_of_sections_in_table_view(view: UITableView): Int
do return 1
# Number of entries in `section`
#
# By default, we assume that all `items` are in a single section,
# so no matter the section, this returns `items.length`.
#
# iOS callback: `numberOfRowsInSection`
protected fun number_of_rows_in_section(view: UITableView, section: Int): Int
do return items.length
# Title for `section`, return `new NSString.nil` for no title
#
# By default, this returns no title.
#
# iOS callback: `titleForHeaderInSection`
protected fun title_for_header_in_section(view: UITableView, section: Int): NSString
do return new NSString.nil
# Return a `UITableViewCell` for the item at `index_path`
#
# By default, we assume that all `items` are in a single section.
# So no matter the depth of the `index_path`, this returns a cell with
# the view at index part of `index_path`.
#
# iOS callback: `cellForRowAtIndexPath`
protected fun cell_for_row_at_index_path(table_view: UITableView, index_path: NSIndexPath): UITableViewCell
do
var reuse_id = "NitCell".to_nsstring
var cell = new UITableViewCell(reuse_id)
# TODO if there is performance issues, reuse cells with
# the following code, but clear the cell before use.
#var cell = table_view.dequeue_reusable_cell_with_identifier(reuse_id)
#if cell.address_is_null then cell = new UITableViewCell(reuse_id)
var index = index_path.index_at_position(1)
var view_native = get_view_from_native_list(table_view, index)
var cv = cell.content_view
cv.add_subview view_native
return cell
end
end
lib/ios/ui/ui.nit:498,1--596,3