Table View not showing up as expected - ios

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)

Related

Static table cells with detail

I'm trying to make an iOS 'information' or 'guide' app in Swift. I wanted to utilise the Master Detail template so that when the user clicks a cell it will take them to a relevant ViewController with either basic text labels or a PDF file.
From what I understand, Dynamic Cells can be dynamically changed whilst the app runs however I want to set static cells from the storyboard (or programmatically) and their relevant content/PDF files so the user can view each one. I don't want any "new cell" or "editing" functionality.
How can I make this work? I would post my code so far but it's almost identical to the Master Detail template so I don't see any use. I know this is quite a vague question but I need help and don't know where to start.
Any help will be so appreciated!
A static table cell can entirely be created via storyboard. In the storyboard once you add a tableviewcpntroller you can prototype call added to it.You can add as many prototype cells to your table ( not necessarily every one should have common layout). After all cells are added you can assign individual tags to the cells if you need identify these cells from your code.You can add segue from each cells to move to different page.
Let me know if something more is needed.
In Interface Builder set the Content of the table view to Static Cells.
Drag as many table view cells as you need into the table view.
In the controller create IBOutlets for the labels and the other UI elements.
Connect the outlets in Interface Builder.
Rather than using the datasource methods assign the values directly to the UI elements via the outlets.

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.

Drag UITableCell onto UITableView

I'm fairly new to iOS development and want to create a simple form using a grouped UITableView with UITabelCells to lay-out the form's contents. I want to do this interactively in XCode5.
My problem is, having added a UITableView to the xib, I can't edit its contents in XView. I had anticipated being able to drag UITableCells onto it. Is this possible in XVIew, or do I have to create the table's contents programatically?
You cannot directly edit tableViewCells inside the TableView using xibs. It sounds like you want to use what are called prototype cells. These can only be created using storyboards. Here's a tutorial for prototype cells:
http://www.raywenderlich.com/5138/beginning-storyboards-in-ios-5-part-1
From iOS 5 and above Storyboard are being primarily used to design the app interface rather than xib.
With your view controller opened in storyboard you can define how the cells looks like for the tableview ( prototype or static content based)
Here is one example
You can read more on it in the docs
https://developer.apple.com/library/ios/documentation/userexperience/conceptual/tableview_iphone/TableViewCells/TableViewCells.html

Unable to use Static Cells in UITableViewController

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.

Resources