Unable to use Static Cells in UITableViewController - ios

I need to use static cells in my app. I am using Xcode 5 and testing thins on iOS 7 simulator (iPad).
I dragged out a new UITableViewController in storyboard and set the tableview's cells to be static. Then I added a Label to the first cell to check if static cells are working. I ran the app and I got blank cells (dynamic form).
Then I added a class that implements the datasource and delegate methods of a table and attached it to the controller in storyboard. Yet, nothing happened. Finally, I embedded it in a UINavigationController and still, I get plain blank cells like the one below:
Could you tell me whats going wrong here, i.e., why wont my static cells show up!?
Regards

if you use static cells you dont need the datasource. so delete all methods that belongs to datasource, such as cellForRowAtIndexPath. After deleting the methods your label should appear.

Related

Table View not showing up as expected

I'm pretty new to Xcode and I'm learning. I'm trying to make a test app. I can't get it to show up in the app like I set it in my storyboard?
Add a UITableViewController and assign it to your tableView. And FYI in Xcode you design one cell only if you are using dynamic cells and the population of the cells will all happen inside your UITableViewController (hence the name PrototypeCell)

Issue with programmatically added buttons

I have a cell in the UITableView. The cell has a UITableViewCell class. In this class I programmatically add few buttons.
Note: the cell is located in the very end of the table view.
Issue:
If I'm using simulator iphone 5 > the buttons will be shown.
But if I'm using simulator iphone 6+ > the buttons will NOT be shown.
Note: when i'm opening it on iphone 5 I need to scroll to see that particular cell. on iphone 6+ i don't need to scroll there, the cell is visible right away.
So I think the issue is somewhere here. May be with the place where I do my 'buttons adding'.
Where should I call the method that sets up the buttons?
Or how can I solve this problem?
TL;DR: If you have different cell types in your table view, you should make sure they have different identifiers.
Explanation:
Table cells are re-used within the UITableView and when the table is first being displayed it won't have any re-usable cells yet. It gets the cells to display by calling on its data source through the UITableViewDataSource protocol.
The thing providing the cells will first ask the table view if it has any re-usable cells (of a particular type), before creating a new one. The way it determines the particular type is from the reuseIdentifier in the table cell.
So, if you have two different classes of table cell, but they share the same reuseIdentifier you will sometimes get one class and sometimes the other - if you get the one without buttons when you're expecting the buttons then this will be a problem!
The answer is to make sure your different cell types have a unique reuseIdentifier.

Can't even get a UITableView to show

I'm starting to learn to program and I'm already getting a really annoying problem. When I follow, step by step, the Apple Developer guide "Start Developing iOS Apps Today" and I add a UITableViewController (even if it's the only view controller in the project) and I set it as the initial ViewController, I run the app to check if it works and I can't get the table view to show, all I see is a blank static background.
It doesn't matter what kind of cell I use, the table view doesn't appear.
What am I doing wrong?
Xcode 5.1, target: iOS 7.1
How to get UItableView to show
Drag a UITableViewController to the storyboard
Give your prototype cell an Identifier (e.g "cell")
Create a Objective-C class file that inherits from the UITableViewController Class.
Assign that class to the ViewController you dragged
Return at least one section
Return at least one row per section
Set a text for the cell in cellAtRowIndex
I created a DEMO PROJECT for you, see how I did things over there.
You can't show a blank table, you need content to show to be able to see your table.

Custom UITableViewCell using storyboard with some cells

I have a TableView in which a most cells are pretty standard. I make them buy using static cells in Storyboard. However, one cell I would like to customize probably using an XIB file so I would need to load it programmatically.
In the TableView's data source, is it possible to handle loading XIB view for this particular cell only, while leaving other cells to what's delineated in the static cells in the Storyboard? Or is it an all or nothing thing where I need to just give up using static cells altogether?
The rationality for doing this is that I would like to make Storyboard to look as close to the real thing as possible. Right now if I provide a data source, the static cells in the storyboard would have no effect on the actual output and is not in any sense linked to the actual output.
Yes, it is possible. Set the custom class for the custom cell. If you wish to customise it from code, just connect it as an IBOutlet to the UITableViewController.

Why are my static prototype UITableViewCells from Storyboard showing up blank?

I defined the static prototype UITableCells, subclasses, outlets, etc. in the storyboard, but when I run the app and go to that viewcontroller/scene, the cells are there, but they have no content?
When you set up a table view with static prototype cells in Storyboards, you do so by having dragged out a UITableViewController and then subclassing it.
The trouble is that UITableViewController is oh so helpful and supplies datasource methods for you to override.
Force of habit had me getting in there and supplying default implementations for those datasource methods.
Turns out that not only do you NOT have to supply datasource methods, but if you do, they interfere with proper display of static prototype cells. I just commented out all of the datasource methods in my viewcontroller and everything started displaying fine.

Resources