Monotouch - Populate a UIViewPicker - xamarin.ios

Is there a quick way to populate a UIPickerView with values?
I have the picker in a XIB all by itself, and when the view is displayed, I would like to have the UIPickerView populated.
Would someone please enlighten me!!
thanks
tony

You need to create a class derived from UIPickerViewModel, supplying implementations for GetComponentCount/GetRowsInComponent/GetTitle.
Then, in the controller associated with your nib, assign the "Model" property of your picker to an instance of your UIPickerViewModel derivation.

Related

Custom Page Type Property with Inheritance

I'm looking for advice on how I might implement a custom property on a page type that supports inheritance.
The sort of functionality I'm looking for would be similar to how the "Use output cache" radio buttons work on the Properties > General page in portal mode.
So I want to be able to create a property on a page type, see radio buttons like this, and then based on whether I choose yes, no, or inherit it will go back up the content tree to find the value to apply to that property (if inherit is selected of course).
I hope that makes sense.
Thanks
Jay
Not sure if I understand. So you want have a dynamic property for your page based on parent's value at the moment of creation. You can access parent object like so:
{%EditedObject.Parent.FieldName%}
You may try to create field with radio button control to choose a value.
0; No
1; Yes
{%EditedObject.Parent.FieldName%}; Inherit
Hope this gives you some ideas

How to find programmatically (SSJS) what item of the underlying doc the UI input control on Xpage is bound to?

The task is that I need to update the field of the underlying doc only given the id of the edit box or the combo box on the Xpage. All that has to happen before the page is actually saved. Cannot find any methods in UIComponent and subclasses that allow to find out the name of the actual doc item the current XSP input control is bound to. Plz help.
The following will get the Expression Language binding for a component with the id inputText1:
var inputText1:com.ibm.xsp.component.xp.XspInputText = getComponent("inputText1");
var valBinding:com.sun.faces.el.ValueBindingImpl = inputText1.getValueBinding("value");
return valBinding.getExpressionString();
This will return e.g. "#{document1.myField}". Using basic string parsing, you should be able to get what you want.
Like Oliver, I'd be interested to hear the use case. It's not something I've had the need to use.
As a bonus, try looking in the Local folder in Package Explorer at an XPage / Custom Control. You'll see all the getters / setters for components on your XPage, which will give you hints for what properties and methods are available. F3 and F4 are very useful for seeing all methods/properties and class hierarchy.

Wrong View shown (Catel)

I'm trying to open a View with a ViewModel from my MainWindowViewModel.
It works, but all I get is a blank window. It binds the correct title but every other control is missing.
Did anyone have the same problem and found a solution?
You forgot the call to InitializeComponent in your code-behind. Just a tip: create a base class with the Catel behaviors, then use that as a base view. It will keep your actual window code-behind much cleaner.

MonoTouch.Dialog: Dismissing a Keyboard

Using the Reflection API to auto generate a UI.
How can I dismiss the keyboard when the user selects a new field, or if they choose a field which generates a new view to pick from. In the later case, when the user returns to the first screen, the old keyboard is still there.
UIView.EndEditing(bool force);
The above will hide the keyboard for you without needing to know who the first responder is. I haven't done much with the reflection API but you should be able to call that on the view when an element is selected.
Apple Docs -- endEditing:
Clarification for those initially struggling with the MonoDialog portion of the question:
The EndEditing method is not available on DialogViewControllers objects directly (who inherit from UITableViewControllers). You should be calling EndEditing(bool) on the View of a DialogViewController and not trying to call EndEditing(bool) on the actual DialogViewController itself.
For clarification:
DialogViewController dc;
dc.View.EndEditing(true);
Note:
UIView objects include the EndEditing(bool) method, but UITableViewControllers do not inherit from UIView so the EndEditing method is not available on the controller itself. UITableViewControllers contain a view object, call EndEditing on that view object.
Check the ResignFirstResponder method. This one should help you I guess.

Updating an AnnotationView Callout after details entered in View Controller that was pushed form the map view

I have a simple maps app with multiple pins on a map view. My intention is to tap a pin, show a callout with an accessory view, push to a Detail View Controller where you can edit that pin/locations details. This all works fine, but once i pop the Detail View Controller the callout on the map view is still there, which i want, but it still has the old uneditied values. How can i refresh/update the callout view once the Detail View Controller is popped?
I am using Core Data with a simple database. I have tried using controllerdidchangecontent, Map View Controller Will Display methods etc but my main problem is identifying which object has been added/updated/deleted and which is the corresponding callout/selected pin.
Any help appreciated...
Not sure if you had find your answer but the way to do it is to extend MKAnnotation class and creating custom annotation and passing them while creating placemarks. Later you can get them from MKAnnotationView's annotation property.
See a good implementation here
http://www.slideshare.net/360conferences/getting-oriented-with-mapkit-everything-you-need-to-get-started-with-the-new-mapping-framework
The only way I could find to update the callout info was to mess directly with the subviews of the callout.
The callout view is the first subview of the annotation view.
In the following example, I update the subtitle.The title label is the 6th and the subtitle is the 7th subview of the callout:
if (myAnnotationView.subviews.count > 0)
((UILabel*)[((UIView*)[myAnnotationView.subviews objectAtIndex:0]).subviews objectAtIndex:7]).text = #"Some example";

Resources