Where is my NSTableView in NSScrollView? - objective-c

Why in Xcode 4 (i don't kwow in 3.2) when i drag and drop a table from interface builder it became NSScrollView? Where is NSTableView??? (NSTableView in NSScrollView)
How can i access NSTableView from NSScrollView?
How can i add a row, delete, customize and RELOAD DATA?
Why if i do
for (id obj in scrollView.subviews)
NSLog(#"obj: %#", obj);
i don't able to get NSTableView description?
thanks.

XCode automatically embeds the table in a scroll view for you. To select your Table View you can either slowly double click on the Scroll View, press control+shift and click on the Scroll View, or click the right-facing triangle under the vertical objects in the XIB to reveal every object in the XIB.
You can access it programatically by calling [scrollView documentView], because it is technically a subview of the ScrollView's Content View (an instance of NSClipView)
To populate your table view you can provide content by hooking up a data source, or by binding its table columns to an array controller.
It's kind of complicated, you should probably take a look at the Documentation

To access the tableview just connect the tableview with the code (IBOutlet NSTableview *yourTableview) then access it easily like [yourTableview reloadData]; Dont bother about the scrollview

Inside "Bordered Scroll View" there is a "Clip View" and inside there is a "Table View". This one you need to connect with your code.

Related

Create UIPopOver without including Tableview in ios

I want to create two PopOvers when at the time button clicked and textField clicked in the same UIView (not ViewController). In those popovers I need to load separate array values. Is there any way to create them and added to UIView?
I already added one tableview for base UIView, so without using tableviews, how can I create UIpopOvers and load the arrays in those popOvers? How to handle the selected rows?
This link can help you to create a popover menu.
Or you can take an UIImageView having shape of popover menu and table view in that, it will be easy to load arrays and to handle selected rows.
I did the same using second method.
Happy Coding!

Showing Toolbar on 2nd ViewController

I have two view controllers on the same storyboard. What I want to do is send an array of string values to the table view control on another view controller.
ViewController2 *second=[self.storyboard instantiateViewControllerWithIdentifier:#"View2"];
second.arrayFromVC1=areaArray;
[self presentViewController:second animated:YES completion:nil];
The second view controller has a toolbar control at the top by default. (See below.)
Passing data to another view controller wasn't easy for me, who has been using Xcode for two weeks. I somehow managed it. So an array of strings is sent to the 2nd view controller through an array variable (arrayFromVC1) set on the 2nd implementation file. I suppose experienced Xcode users know what I'm talking about. Anyway, the 2nd view controller does receive a list of values as shown below.
Well, the problems are that the toolbar control on the 2nd view controller will disappear when the user gets to see the list and that the table view control (UITableView) occupies the entire window. I understand that you can control the size of the table view control by specifying values under the viewDidAppear method. But my question is... Is that how things work with iOS and Xcode? So if I want to display that toolbar control at the top, I have to do it programmatically by writing code under the viewDidAppear method as well?
Thank you for your advice.
Tom
Tom, are you using interface builder and storyboards? If so, select the ViewController in IB, go to Editor (in the top menu) --> Embed In --> Navigation Controller.
This will embed the chosen VC and any VC it segues to (and so on) into a Nav Controller.

Combined UITableView with other elements - how to create and use the view?

Ive a project close to doing everything I need it to do. Its got a Main page which has four buttons that allow you to choose an option. Then a tableview page is launched from those options and displays a parsed XML feed from a website. You can then select one of the options in the table to see a detail view of the item, enquire about it, etc.
My problem is I need to add more elements to the TableViewController page, other than the tableview itself. I want a customized back button (not the navigation controller standard) plus some labels, images, etc.
In the TableViewController xib, the tableview itself fills the page. I cant resize it to add more elements above it. I can add a 'view' window seemingly above the tableview and put things in it. But it seems to add the view to the tableview. This means that when I scroll the table, the other elements like new back button, scroll away as part of the table.
So I'm led to wonder whether I need this page not to be a tableviewcontroller, but a viewcontroller, with a tableview inside it, as well as my other view with buttons, etc. Is that the right way to go? But if thats the case, then how do I instantiate the tableviewcontroller within code? Because my page will not be of that type anymore - it will be just a viewcontroller. But in code Im making a tableviewcontroller .. slightly scared by that route tbh.
Any illumination on this would be much appreciated, as various searches have left me none the wiser. Thanks.
To customize it, this is the way to go:
Change your class to be a view controller instead, which implements the TableViewDelegate and TableViewData Source protocols.
In the view didLoad of you controller, create the table view, set its delegate, data source, and any other properties you wish and add it as a subview to your view.
tableView = [[[UITableView alloc] init] autorelease];
tableView.delegate = self;
tableView.dataSource = self;
// .. Other customization
[self.view addSubview:tableView];
I suggest doing this programatically rather than IB.
Instead of a UITableViewController, you want a UIViewController that has an IBOutlet UITableView. Drag and drop a UITableView component from Storyboard and hook it up, and position it as needed on the screen. This UIViewController should implement the UITableViewDelegate and UITableViewDataSource methods.
Edit: Remember that a UITableViewController is just a subclass of UIViewController so you don't really have to get rid of all your code. :) You only need to make minor tweaks to your header and main file, and change the Storyboard to be a UIViewController instead of UITableViewController as I mentioned above.

Add other objects to iOS 5 storyboard after tableview

I have a simple iOS 5 storyboard that contains a tableview controller scene. However, the table UI takes up 100% of the real estate and I am unable to add any additional objects such as a title bar. Any object that I drag to the scene will try to size correctly and what-not but as soon as I let go it will not add the object. What am I doing wrong?
If all you want is a title bar, then it looks like you want to embed your table view controller in a navigation controller. You can do this by selecting your table view controller and using the Editor: Embed In: Navigation Controller menu command. Once you do this, you should have a navigation bar, and you can double click it to edit the title.
If you need arbitrary UI elements along with your table view, then I think you need to use a plain UIViewController scene instead of a UITableViewController, and manually drag a UITableView into the scene. Your view controller would not subclass UITableViewController, instead it would subclass UIViewController and implement the UITableViewControllerDelegate and UITableViewControllerDataSource protocols. Also, you would need to manually wire up the delegate and dataSource outlets by ctrl-dragging from the table view to your view controller in interface builder, and your view controller would need a custom tableView outlet that points to the UITableView and is correctly wired up in IB. Perhaps there is a simpler approach than this though, if someone has a better suggestion that would be great to hear.

UISplitViewController: how to get toolbar if details controller is UITableView?

I checked out Apple's example on how to exchange detail views in the UISplitViewController and it seems that they put the UIToolbar in every detail controller. Then, if the device is rotated, they hide the toolbar or show it and add a popover button which will show the root controller.
I'd like to adopt this pattern to show my root controller in a popover using a button in the toolbar, but unfortunately, my detail controllers are all UITableViewControllers and they do not allow adding other UI elements than a table view. So how do I deal with that? Is there an example around?
René
I think I figured out by myself: DON'T use a ´UITableViewController´ and a UITableView as root view in your NIB, as you cannot add a UIToolbar to the table view.
Instead: In the NIB, put a standard view and drag a UIToolbar and a UITableView on it.
Connect the standard view to the controller's "view" outlet.
Add another outlet and make it a UITableView. Connect the table view to it.
In the code: Let your controller inherit from UIViewController and not from UITableViewController.
Add a property to your controller to get the TableView to make it look compatible to UITableViewController.
public UITableView TableView
{
get { return this.viewTableView; }
}
Upon the viewDidRotate event you will have to adjust the table views width and height now (UITableViewController did that job for you before):
this.TableView.Frame = new RectangleF(0, 44, this.SuperView.Frame.Width, this.SuperView.Frame.Height);
The 44 pixels com from the parent view's toolbar.
I don't miss UITableViewController. I know there are some issues like automatic scrolling when editing, but in my case this is simply not needed.
René
Check out this example and the corresponding code. If I understand your question, this should show you how to do what you're looking to accomplish.
Also, just as an FYI to everyone, another MT user MonoTouched the MultipleDetailViews example that you linked to above.