I have a table view inside a normal view controller and I was wondering how I should go out populating it with data?
After researching it, everywhere I have seen it done uses a table view controller: I am just using a view controller with a table view inside it.
How should I populate this with data? I have created an IBOutlet in my ViewController.swift, but I'm not sure what to do to add data.
The reason I am not using a table view controller is because I couldn't get the navigation bar to show up and I heard that the navigation bar scrolled.
Is it possible to use a table view inside a normal view controller? Should I be using table view controller? If it is possible to use a table view inside a normal view controller, how do I populate the table view?
The coding language I am using is swift.
A UITableViewController is basically a normal UIViewController which has its main view replaced with a UITableView and uses the UITableviewDelegate and UITableViewDataSource protocols.
UITableViewController is subclass of UIViewController.
So just add the protocols and use it exactly the way you use it in UITableViewController.
Related
I've been transitioning my programmatically-created user interface over to interface builder, but I'm still fairly new to IB. I have a custom view inside of my main view (in the IB .xib file), which I want to link to its own view class, and, more importantly, its own view controller.
I know that traditionally, one references the custom view class from the IB property, and then uses -awakeFromNib in the custom view class to set up the view programatically.
However, I can't figure out how to reference the custom view controller class. How to I tell my custom view what it's controller should be? And is there a way to instantiate a view controller from IB, or should I be doing it from -awakeFromNib?
Advice would be appreciated :)
Obj-C please!
I am looking for a way to create a TableView to show a list of posts on a social networking site. I want to place the exact same prototype table in several ViewControllers and based on the current ViewController, it will be populated with different information. Is there a way to do this with Storyboard? I assume that this is quite easy using only code, but I would like to drag and drop elements to create the prototype cell.
Thanks
For each view controller you should create a new table view. You could reuse table view cells by creating a custom nib cell and populating each table view accordingly.
This is a good tutorial on how to populate a table view with an rss feed.
https://www.youtube.com/watch?v=NyrGnbzXpxk
You can then find the rss feed of each social media page that you want to include in each table view.
I'm using Storyboards for the first time creating a master/detail view for a simple object.
Both view controller items of the split view have their own view & NSObjectControllers. The controller for the table view is a NSArrayController (which shows all instances of the Entity). The controller for the detail view is an NSObjectController, which shows just the selected instance.
When I click an object in the table, I'd like the detail to show up in the detail view. So I believe my goal here is to bind the 'contents' of the detail object controller to the 'selection' of the master array controller. However with storyboards I cannot cross view controller boundaries (can't create the IB 'link'. aka: can't bind cross VC).
Whats the best practice for doing this?
So far all I can think to do is manually set all this up in one of the controllers (either the root controller, window controller or perhaps the master table view controller) - but that seems counterintuitive. That seems to defeat the purpose of being able to lay out this stuff within storyboards in the first place, and my controller of choice would then have to know about the other controller specifically.
I must be missing something!
I have an NSTabView that has different styles of NSTabViewItems. Is there a way that I can separate out the tab controller into a different class than my outerview controller? Just so that I can keep my code tidy. I'm also looking to keep the tab contents in a separate nib.
Note: This is for the NSTabViewItem NOT for UITabs (not the iPhone).
Sure, but it takes a bit of setup in code. Create the separate NIBs, one for each view. Create a custom subclass of NSViewController to load and own each NIB and control the view within. Set the class of each view NIB's File's Owner to be the corresponding class. Connect outlets as desired.
The tab view would be basically empty when you configure it in its NIB. You'd add the tabs, but nothing in the views.
In the controller for the NIB with the tab view, in -awakeFromNib, instantiate the view controllers for each of the views that should go into the tab view. Set the views of these new view controllers as the views of the NSTabViewItems of the tab view.
I want to implement a navigation bar. When I add the nav bar controller it adds a table view. But I don't want a table view! Is there a way to reset that relationship to a different view type?
May be adding it as a subview could be a solution?