Adding Custom class in TableViewController in swift - ios

I've been trying to add a custom class named ThirdViewController to My TableView controller which is a third tab of my Tab Bar Controller. When i try to use a View Coontroller it displays but for table View controller which is required, it doesnt show any suggestion in my custom class.PFB the image for the same. Image here

You can simply try creating UIViewController class and then use UITableView in that view controller

Related

referencing outlets with new view controller table view

I've an button in my storyboard's main view. now I need to open an new table view in new screen when this button will be clicked. For this, I've
1. dragged an new view controller in the empty space on storyboard.
2. dragged an table view inside this new viewcontroller.
now not able to define this new table view in ViewController.swift. ctrl + drag from table view to ViewController.swift not opening any dialog.
any idea what wrong am I doing here.....
From the details you have given, it looks like you have not set your viewController Class. Create a custom view controller class. Specify this class as the custom class in the Attributes inspector for the viewController scene and try adding your tableView.

Putting a navigation controller with hierarchical table views inside of a view controller in swift

I am making an iPad application which requires the use of a "drill down" style set of table views for users to add elements to a list (i.e. a user taps on a table view cell and it brings up more detail or options, like you would see in settings). My problem is that I need to be able to place this table view inside of a view controller amongst other content. I can add a table view, but I need the navigation bar at the top of the view in order to mimic a tableView inside of a navigation controller.
You need to use a UIViewController and
give it a tableView property
make it conform to the UITableViewDataSource protocol
make it conform to the UITableViewDelegate protocol
Navigation controller works exactly the same way regardless if you use a UITableViewController or UIViewController. Create storyboard segues and inform the detail view about the object to be displayed in prepareForSegue.

UIView below UINavigation bar on each screen

I want to add UIView below UINavigation bar on each screen. I don't want to add it on every viewcontroller explicitly. I want to add a view in parent class so that the rest of the views in every viewcontroller starts below the view that I added below UINavigationBar. Currently, I have added a view in parent class but it appears over the views in child classes. Any solution?
Here it is i got one very nice helpful github project for show a custom message view under thenavigation bar here is link TSMessages
Make your custom UIView in xib and use inheritance concept. Create a BaseViewController and all other view controller should be subclass of your BaseViewController. Load your custom UIView in BaseViewController it will be there all other subclasses

UITableViewController inside a UIViewController

I'm new to iOS and objective-C and I'm having some trouble in understanding how controllers work.
In my code I have a UIViewController (with my custom controller assigned by storyboard) and inside it, together with other objects, I want to have a table handled by a different controller. What is the right way to do this?
You can make that table view controller a child view controller of your UIViewController.
In the storyboard, you can do this easily by dragging a container view into your controller's view, and that will give you a child view controller automatically.
You'll want to:
delete the child view controller it gives you (it's just a UIViewController)
drag out a table view controller
control drag from the container view to the table view controller
choose "embed".
If you need to get a reference to this table view controller from the UIViewController, you can do that in prepareForSegue -- the table view controller will be the segue's destination view controller, and prepareForSegue will be called right after the controllers are instantiated.
You'll want to use an embedded container view.
Drag a "Container View" from Interface Builder sidebar into the view. This adds and links a default "contained" UIView/Controller as well.
Delete the entire UIViewController and View that was automatically added and linked to the container view (as you'll want a Table View Controller instead).
Drag a UITableViewController onto the Storyboard canvas.
Control-Drag from the Container View to the Table View Controller. Select "Embed" to contain the UITableView within the container view.
You're left with the parent view, now containing a UITableView via a Container View. The Controller for the Table View is on the storyboard canvas as well.
Add UITableViewController to storyboard, And create subclass (new file) of UITableViewController. In Storyboard go to Identity Inspector and in Class field type name of the subclass you created. After that you have to add your app logic based on your requirements.
Create Another UITableViewController in the storyboard, go to its inspector and assign it the same UITableViewController class that you have created before...

How can i define a NavigationController that embeds a ViewController?

I have seen a project with the following storyboard:
http://www.disclafani.org/vc.png
I would like to know how it has been built the CustomerPagesViewController as NavigationController, i don't see a RootNavigationController for it.
In short terms ... how can i define a UINavigationController that embeds a ViewController?
When you drag and drop a navigation controller in storyboard, it will create two controllers (two scenes to be more precise): a navigationbar controller and a tableview controller that will be defined as your rootview controller. All you have to do is replace your tableview controller by your custom controller: it will be embedded in your navigation controller.
EDIT
Sorry I think i mislead you in my first answer: it doesn't look like you can simply replace one controller by another. If you want a custom view controller embedded in a navigation controller a better approach would be:
Drag and drop a view controller on storyboard
Reference your custom view controller by editing the custom class field in the identity inspector
Drag and drop a navigation controller on storyboard
select your custom view controller and select from editor the embed in option by choosing navigation controller: your navigation controller should now contains your view controller. You can deleted the tableview controller that was created when you drag and drop the navigation bar controller.

Resources