In my App I want to display a TWTRTimelineViewController (TableViewController) in an UIViewController. But the Code for the TWTRTimelineViewController is only working in an UITableViewController Class and not in an UITableView Classe. Is there a way to solve this, for example to display an UITableViewController at a y-postition in an UIViewController?
Thanks!
You should create a UIViewController than include a tableView using the storyboard and connect it with the UIViewController (#IBOutlet). Next you will set a identifier to the tableView prototype cell. Than in your UIViewController you will extend the delegates UITableViewDelegate and UITableViewDataSource and implement the protocols.
This tutorial is pretty much detailed and will give you all the steps to achieve what you expect.
You can not set UITableViewController custom class in UITableView,if the 3rd party class you are using is UITableViewController then you must use it in UITableViewController from storyboard
Related
I have a UIViewController which contains a UITableView (amongst other views).
The UITableView could get its cells from one of two UITableDataSource, depending on some condition.
My UITableDataSource class also acts as my UITableViewDelegate.
When a cell is selected (tableView:didSelectRowAtIndexPath) I may want to perform an action on the UIViewController, such as performSegue or show an alert.
What would be the best way to do this?
Add a weak reference to the UIViewController inside each datasource/delegate class
Create a delegate per datasource/delegate class which calls functions inside my UIViewController
Your suggestion here!
I considered making my UIViewController the UITableViewDelegate but as the cells are different depending on the source I thought it would get messy.
Note: I say "best way" but really I am just interested in alternate approaches
The most common approach is to subclass UITableViewController and implement UITableViewDelegate and UITableDataSource there. You can return whichever cell you require in cellForRowAtIndexPathbased on any state in your controller class.
I'm new to Swift/iOS development.
I have a UITableView in my storyboard that I want to populate with some data. In my attempt to do so, I created a class that inherits from UITableViewController. The implementation is not yet complete, but my understanding is that by inheriting from this class I can provide an IBOutlet to both dataSource and delegate.
When I try to drag the outlet into the source file, I don't get the insertion point that I got when I tested this before. See image below:
What do I have to do to define this class as the handler for the UITableView?
Set your viewController to inherit from UIViewController, not from UITableViewController (It seems like your IB is set up like that).
Do not forget to set your class to ZeroconfTableController on the interface builder.
Than, you will be able to set the delegate and datasource. NOTE: the delegate and the datasource will not create IBOutlets.
Assign the delegate and the dataSource the following way:
Also make sure, your viewController conforms to the protocols.
class ZeroconfTableController: UIViewController, UITableViewDataSource, UITableViewDelegate {
In your storyboard, select the UITableView and change this to the name of your UITableViewController subclass. You then do not need to do any linking stuff.
If you're using your own UITableView, inherit from UIViewController, not UITableViewController.
If however, you want to use a UITableViewController (which personally I don't use) in your storyboard, then do inherit from UITableViewController. In this case you won't have to wire up the UITableViewDataSource nor the UITableViewDelegate.
I need to create a UIViewController which has a UITableView inside it. I found some similar questions on here but I want to use a separate class a my data source and delegate, a class that will subclass PFQueryTableViewController from Parse SDK.
So in my storyboard I have one UIViewController with one UITableView on it.
I also have a class called ArticleTableViewController (inherits from PFQueryTableViewController). I would like this class to be the delegate and the datasource for my table view, but I donĀ“t know how to connect them correctly.
Any ideas?
I tried to do something like this, i've got the answer: you can't use the PFQuaryTableViewController as a subclass of a UIViewController.
Here's my original question with the answer and some useful suggestions.
I need to add a common method to all my view controllers no matter what type they are. I notice though that some of my viewcontrollers inherit from UIViewController and some from UITableViewControllers.
How do I write a subclass that can be used for both?
UITableViewController inherits from UIViewController, so if you want to be able to call your custom method from both, you can write a category on UIViewController and then call methods from that category in any subclass of either UIViewController or UITableViewController. Here's a link to Apple's docs on categories and extensions. http://developer.apple.com/library/ios/#documentation/cocoa/conceptual/objectivec/chapters/occategories.html
if you add a category to UIViewController, you will be able to call those methods on UITableViewController subclasses, as UITableViewController is a subclass of UIViewController
I like to accomplish an UIToolbar below an UITableView and I wanted to use the UITableViewController because it sets up the data source and delegate and other stuff on its own.
I don't need an UINavigationController as has been proposed in similar topics due to only having 1 view currently and my data is without a hierarchy.
I didn't manage to drag and drop an UIView or UIToolbar to my UITableViewController at any place (scene design area or view hierarchy) in Interface Builder of XCode 4.2.
Thus my question: How to add an UIView to an UITableViewController in Interface Builder?
I did manage to achieve the look I intend to accomplish using an UIViewController with an UITableView and an UIToolbar contained in its UIView.
Would using an UIViewController with an UITableView be much more involved than relying on the UITableViewController?
Thank you for your time!
I think this is your real question
Would using an UIViewController with an UITableView be much more
involved than relying on the UITableViewController?
The answer is no, its not much more work. Just add this to the viewcontrollers' .h
#interface MyViewController : UIViewController <UITableViewDataSource, UITableViewDelegate>
Then in the .h add the datasource and delegate functions( you could just copy and paste the functions your'e currently using in your TableViewController)
NOTE: From Xcode 4.5.1: "Static table views are only valid when embedded in UITableViewController instances."