Using a UIPickerView with custom values - cocoa-touch

Im using a navigation controller and a normal view. In the view I'd like a UIPickerView with custom values in it. It would have one column with about 15 values in it. And I want the ability to add an action to each value.
Is there any way I can do this using Xcode? I can't seem to find the corrent help.
Cheers.

You need to look at the documentation for UIPickerViewDelegate.
In order to have an action for each value you will implement pickerView:didSelectRow:inComponent: and have a different action based on which row was selected.
For the contents of the rows you can implement pickerView:titleForRow:forComponent: if your contents are simple text.
If you want custom drawn contents you can provide a custom view for each row with the pickerView:viewForRow:forComponent:reusingView: method.
See the UICatalog example that is available in the iPhone Developer examples.

Related

Tab Bar iOS - Filter Core Data Only

I have a concept question, that i am having real issues with.
I have a Master/Detail application that i would like to add a Tab Bar to, but only to filter core data, basically just changing the predicate for the Fetch Request.
Now, i could add a Tab Bar, add my Navigation Controller to it, modify some code and make it work. But i would then need to create multiple screens/fetch controllers e.t.c for each view i wish to display. Whereas what i would like to do is just re-filter the results on a change in the Tab Bar.
Please excuse me if this is a stupid question, i am coming from an OSX background, and on that it is very straightforward!
Thanks in Advance!
Gareth
UITabBar is a type of view, so you can add it as a subview of one of your existing views and set yourself as the delegate. Then you can update your fetch request in the tabBar:didSelectItem: method. You don't need to use UITabBarController.
It seems easiest to just create multiple instances of your view, each with an appropriate filter property set and then add all of those instances to your Tabbar controller array.

List with 3 columns editable on the fly

I want to add in an iOS App a list with 3 columns, but I also want that each field could be editable on the fly by clicking directly on it and when I press return it saves the field.
Currently I am using Xcode 4.6.1 and storyboard.
Here is the idea:
Because I am a beginner, I am asking you if there is a way to do that by using the UITableViewCell, UITextField and UITextView or there is something else to create this list faster.
Can you provide me some links with tutorials or similar, please?
Another question is: because each field (Label1,1; Label1,2; L1,3) will refer to the same object (eg.: cable; [size]1 meter; [diameter]1 cm), is it better to put each row in a NSMutuableArray or put everything in a SQLLite Database?
Hope in some hints.
You can create custom cell. I answered how to do it here
And add gesture recognizers for each object on the cell.
Change values and reload data.

Static Grouped UITableView without storyboard

I've been searching and can't find an answer anywhere. I want to a create a really simple grouped table view for "settings" of my app. User taps a button and I want to load a UITableView that has 3 or 4 cells in categories. Is there a way to just set one up in IB without the dynamic code building (ie. cellForRowAtIndexPath).
Note: Most answers I have found pertain to storyboard, which I am not using.
No, you can't. tableView:cellForRowAtIndexPath: is the way a table gets its data -- there's no way to populate a table without that in iOS (in OSX you can use bindings, but they're not available in iOS).
If you only need a few cells, are you sure you need to use a table?

Handle clicks in table view cell

Im new to IOS developing and i would like, as one of my start projects to learn more about table views. I would like to fill a table view up and then be able to handle clicks on them, to open a webpage etc. Does someone know a good tutorial or code for this?
Thanks!
What you want is the UITableViewDelegate documentation.
Specifically, tableView:didSelectRowAtIndexPath:. You can then lookup the cell at the given indexPath and handle it accordingly. More info on delegation can be found in the docs if you need it, but you'll want to implement methods like that in the object referenced as the delegate of your tableView

Using Custom Cell for Mac Application

Does anyone have any info on this? I'm new to cocoa, all tutorials seem to be for iPhone which uses a different view controller. Anyone willing to provide a step by step for adding labels to a custom cell? (I'm pulling from Core Data)
EDIT: It's important to note I'm using Core Data here. Many tutorials use arrays.. I don't understand why you would use that??
I'll award an answer quickly!
Zach
I'm not sure if this is going to help you, but your problem seems unrelated to your use of CoreData.
If I've understood your problem correctly, here are some steps:
Populate your NSTableView
Using CoreData, what you can do is put an NSArrayController object in your XIB document, set its mode to Entity and choose the Entity you want to display in your TableView (all of this from the first tab of the inspector on your array controller object).
Then, bind your NSTableView Content to the arrangedObjects of the array controller. You might also bind the selectionIndexes and use some sort descriptors on the array controller to order your data, as CoreData will give you a set rather than an array.
Click on your table view as many times as necessary as to select the table column in which you want your custom cell to appear, and set its Value binding to arrangedObjects too.
Set your custom cell
Finally, click on the cell of this table column and in the "Identity" of the inspector, change the class name of the cell to the class name of your custom cell.
I'll let you read the appropriate documentation to implement your custom cell according to what you want to achieve.
With the different bindings I've described, the objectValue of your cell should be the object from your array controller at the same index of the row your cell will appear on.
Please note that I've not tested again all of these steps but answered from memory... there might be details I've missed but you should have the main steps here.