Titanium TableViewCell Module
Titanium TableViewCell Module
Download Now
View On WordPress
seen from China

seen from Canada
seen from United States

seen from Germany

seen from Finland
seen from China
seen from China

seen from France

seen from Malaysia

seen from United States
seen from China
seen from China

seen from Australia

seen from Serbia
seen from China

seen from Malaysia

seen from United Kingdom
seen from Italy
seen from China
seen from United States
Titanium TableViewCell Module
Titanium TableViewCell Module
Download Now
View On WordPress
Table Views
Table views are user interface objects that present data in a scrollable list of multiple rows that may be divided into specific sections. Generally, table views are used for the following purposes:
1. Navigate hierarchically structured data
2. Present an indexed list of items
3. Display detailed information and controls clustered by group
4. Present a list of options for user selection
Table views consist of only one column that allows for vertical scrolling. The table view has rows in each section. Each section can have a header or a footer that will display text or an image. UIKit framework identifies rows and sections through an index number. The index numbers for sections range from 0 to n-1 from the top of a table view to the bottom element; rows are numbered from 0 to n-1 within a section. Table views can themselves have their own headers and footer, distinct from a section header and footer. Table headers show up above the first row of the first section; table footers show up after the last row of the last section.
A table view itself is an instance of the UITableViewClass. It is set as one of two styles – plain or grouped. Plain table views are unbroken lists; grouped tables have distinct sections. Table views have a datasource and might have delegates. Data sources provide – you guessed it, the data that is used to fill in the sections and rows of the table view. The data source mediates between the app’s data model (i.e., the model objects) and the table view. Delegate objects are used to further customize appearance and behavior. The data source and delegate are often the same object, which is usually a custom subclass of UITableViewController. The data source adopts the UITableViewDataSource protocol. UITableViewDataSource has two required methods, the tableView:numberOfRowsInSection: method that tells the table view how many rows to display in each section, and the tableView:cellForRowAtIndexPath: method, which provides the cell to display for each row in the table. The delegate adopts the UITableViewDelegate protocol, which has no required methods. The protocol declares methods that allow the delegate to modify visual elements of the table view, manage selections within the table view, and support editing of individual rows in the table view.
Visible rows within a table view are drawn using cells, which are UITableViewCell objects. Cells are views that can display text, images, or other content. They can also have background views for normal and selected states. UIKit defiens four standard cell styles – each with its own layout of the three default content elements: main label, detail label, and image.
When a user taps on a row, the delegate of the table view is made aware via message. The delegate is passed the index of the row and the section that the row is located in; it then uses this information to locate the corresponding item in the app’s model. The item will be either an intermediate level in a hierarchy of data or a “leaf node” in a hierarchy.
In addition, you can enter editing mode in a table view in which a user can insert or delete rows, or relocate them in a table. When users try to insert, delete, or reorder rows, the table view will send a sequence of messages to its data source and delegate so it can manage these operations.
STUPID MISTAKE OF THE DAY:TABLEVIEWCELL CLASS IN STORYBOARD
I am in the middle of the project that has lots of tableViewControllers. I want to have a consistent look for the cells, which mostly comes down to colors and fonts and whatnot.
in - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
I properly set: MyClassTableViewCell *cell = (MyClassTableViewCell *)[tableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath:indexPath];
and in the storyboard, I properly set the reuseIdentifier to Cell.
and then in my custom Cell class .m file, I first modified self.backgroundColor = [UIColor RedColor] in - (void)awakeFromNib and nothing changed, so then I changed it in - (id)initWithCoder:(NSCoder *)aDecoder and still nothing.
Grumble, grumble.
I knew that I could just make a method in my class to configure the cells, but it since nothing that I wanted to change in these cells is dynamic, then that is over-doing it.
Quick Googling. Duh, didn't set the cell class to my custom class in the storyboard so the visual component was not getting called as it initialized.
Fixed.
Also as a reminder, the value of doing that setup in either the awake/init methods is that they only get called for as many cells as are displayed (plus a couple for top and bottom extra margin) instead of being called every time a cell is dequeued.
Stupid Mistake of the Day:TableViewCell Identifiers
Arrgh! Forgive me if this is so trivial as to be embarrassing, but that's pretty much the theme of the blog.
When I screw up a tableView with custom cells, it's usually somehow related to a screwed up setting in Storyboard.
Past Options for failure:
have not set the class of the tableViewCell
have not set the cell identifier correctly.
have not hit Return after entering text into the cell identifier box and therefore the new cell identifier
have not "cleaned" the project, so the xml did not reflect what was in the visual editor
static NSString *CellIdentifier = @"todayCell"; CBFTodayTaskCell *cell = (CBFTodayTaskCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
Today's version is due to the ambiguous naming of the Cell ID in interface builder.
Wrong:
Correct:
Lesson, don't confuse Restoration ID's with Reuse Identifiers...
Ugggggghhhhhhh