Monodevelop 2.8 Xcode 4 Custom class on xib UI Components - xcode4

How do you set a custom class on a UI component in Interface Builder, so say I have a class in my project that extends UITableView how do I associate a component in Interface Builder to use that custom class? I type the class name into the custom class placeholder but it replaces that with UITableView...
Any Ideas?
Thanks

Make sure you have this mode active (the right hand side pane), your view selected and the third pane selected like this:
http://tirania.org/s/f6111a1a.png
Then just set the name of the class there. When you save the file and switch back to MonoDevelop, it will automatically stub the class for you if you are using Storyboards.

In order to make the class usable from Interface Builder (and Objective-C), you need to register it using an explicit name, for example
[Register ("MyTableView")]
public class MyTableView : UITableView
{
//...
}
Then MonoDevelop will be able to synchronize the class out to Xcode and it will be visible in Interface Builder.
Classes in project and xib/storyboard templates are already registered in this way, though the attribute may be in the partial designer class.

Related

What is the proper way to create control in Xamarin Form PCL?

What is the proper way to create control in Xamarin Form PCL?
In my class library I have "control" class not derived from any View, just a layout with some labels, scrollviews, logic etc.
I am using it in my pages in the same PLC in several places.
My question is - what is the proper way to wrap this "control" and use it in PLC pages?
I ended up having this control class to expose its root layout where I add all the child elements and subsequently add this layout to the children of page layout. This makes this class to be some sort of a builder of a part of UI of a page.
It looks like that using "View" as a base class requires me to add custom renderers to Android and iOS projects
which I don't need to do - all my UI functionality fits into PCL withot the need for any custom work.
I have a feeling that I am not doing it the right way.
Advise and/or link to the documentation on how to properly do it will be greatly appreciated.
It seems to me that you're actually hurting yourself by not wanting to use a View as a base class. I commonly use ContentView as a base class to create my own controls and it works great without the need for a custom renderer since ContentView already has its own renderers in iOS and Android. Something like this should do the trick.
public class MyContentView : ContentView
{
private Layout createLayout();
public MyContentView()
{
Content = createLayout();
}
}

In a tabpage GUI Extension, what does the ext:pagetype node do?

I have a GUI Extension adding a Tab (ext:tabpage) to View.
What does the ext:pagetype node do? I have been using Namespace:Name like the following. Are there other options for the value?
<ext:pagetype>RC.TabExtension</ext:pagetype>
It allows you to have a specific JavaScript implementation for that tab.
If you specify the full name of a JavaScript class and it implements the Tridion.Controls.DeckPage interface, it will use that implementation for the tab.
If it's not a class or it doesn't implement the interface, it will just use the default implementation.
(Tabs inherit from Decks, in case you are wondering)

Exposing properties to a Spark Skin class

I am having trouble wrapping my head around the spark skin class in relation to it's host component. Basically, from what I've seen with most every skin that comes in the Flex 4 framework they don't directly expose the properties that are dynamically being set in the host component. Instead, they define states that get exposed to the skin class to define when a component should look different. This is all fine and dandy when you have a very simple component with a standard set of states, but when you have twenty different properties (hypothetically) to set in your host component that should change how the skin looks it could get very complicated very fast.
The way that I've seen that they have used to get around this is by overriding the commitproperties and invalidate functions in the skin class, grabbing the values for the properties they want from there, and then setting them to a locally instantiated variable inside the skin class. This is fine, but I feel like that is just a patch workaround to it which makes things a lot more complicated than it needs to be.
HERE'S MY QUESTION:
Is there any way to directly expose a bindable property from the host component class so when you define your skin class it is directly ready to be read from? Let's say you have custom button with a boolean property of 'selected'. In the skin class, you want to add in a get and set function for the property 'selected' so you can perform some action upon your skin whenever it's set. How do you tell the skin class that this is an available property for you to work with from the host component?
This question exists at a very theoretical level. I'm not clear what you're trying to accomplish, nor what sort of properties you're setting on your component class. I suspect, there is an architecture problem if you have 20 properties and each one needs to correlate to a different skin states somehow.
However, I can try to answer your specific questions.
Is there any way to directly expose a bindable property from the
host component class so when you define your skin class it is directly
ready to be read from?
When building Flex MobileSkins, they recommend creating a property named hostComponent which gives the skin class a reference to the component class. MXML skins already have a similar property. If you're using a custom skin, this property is created automatically using the HostComponent metadata. Therefore from the skin class you can access properties on the component class using the hostComponent property.
Let's say you have custom button with a boolean property of
'selected'. In the skin class, you want to add in a get and set
function for the property 'selected' so you can perform some action
upon your skin whenever it's set.
I'm not envisioning the situation where you would want to do this. Generally you would not define any properties on the skin class which you intend to explicitly change on the instance of the skin class.
You could dispatch an event from the component class when the property changes. [This is very common]. Then listen for that event in the skin class using the hostComponent property and change things there.
There is also a way to access the skin class instance from within the component class. So you could change properties directly on the skin class using the skin property.
I wouldn't follow either approach without thinking it through. Ideally the component class and skin class should be encapsulated from each other; and each approach would provide dependencies.
When you affect a skin to a component, you can use metatags to store a reference to the skin part you actually use :
[SkinPart(required="false")]
public var resizeHandle:UIComponent;
Then, when overriding the partAdded and partRemoved methods, you will be able to set or unset whatever you want in these skin parts, from the basic properties to event listeners.
override protected function partAdded( partName:String, instance:Object):void
{
super.partAdded(partName, instance);
if (instance == resizeHandle) {
resizeHandle.addEventListener(MouseEvent.MOUSE_DOWN, resizeHandle_mouseDownHandler);
}
}
override protected function partRemoved(partName:String, instance:Object):void
{
if (instance == resizeHandle) {
resizeHandle.removeEventListener(MouseEvent.MOUSE_DOWN, esizeHandle_mouseDownHandler);
}
super.partRemoved(partName, instance);
}
Furthermore, since you have stored a reference to your skin parts, you can still access it whenever you want in your host component and update it. Am I clear ? :-)

Opening a new tab and adding an mxml component to it

Hi
In our flex application we have tabs at the main level and under it we have subview.
e.g
Home / Tasks / Admin etc...
In one condition we have to click on a button and open a new tab, on this tab we have to add an existing mxml component and show it in the tab.
We are using parsley as the framework.
Inside the mxml component test.mxml (that is shown in the tab) i am configuring it with parsley using the tag
Now when i add the instance of this test.mxml i am getting an exception
I am deriving this test.mxml instance using teh parsley context
as
context.getObject(id of component) as DisplayObject and adding it to the tabNavigator...
But i am getting exception when i try to grab an instance of a view using parsley context.
How do i get an instance of a view or component that is configure through parsley using the parslye context.
posting some code
in parsley context mxml file
in mediator class
public class TestMediator {
[Inject(id="testViewID")]
public var testView:TestView;
and then i add this view object to a container....
Also the problem is occuring becuase of the view injection..because i get a parsley excepiton on startup of the application stating that there is some problem in the context.
What exception are you getting? Without this information it's hard to help you out.
Anyways, here are some thoughts:
creating views through the container should not be a problem
note that MXML components can't take constructor arguments, so make sure you don't have any in your object definition
children of the tab navigator should be containers, not just display objects

custom flex component, visual controls in design view

Do you know how if you drag an <mx:Label> or <s:Label> component into your Flex project, when you go to design mode you get this panel on the right to set its properties like text etc.
I have a custom component that I can call with actionscript, or with mxml like this:
<comps:TheComp field1="OK" field2="Yes" />
The component takes this input and uses it for its internal operation
private var field1:String;
private var field2:String;
private function initializeit()
{
// component takes the input and lays it out as needed
}
When I go to design mode, I can see the component under custom components, I can drag it to the stage and see it, but can't set its values field1 and field visually on the right like a normal <s:Label> or <mx:Label> would have.
Any idea how I can add that? Do I need to make it inherit something or anything else
Try using the [Inspectable] metatag in your code
[Inspectable]
private var field1:String;
[Inspectable]
private var field2:String;
Not sure if inspectable members can be private. If [Inspectable] alone doesn't do it, try making the vars public or protected.
You need to put any custom components you want to view this way into a library project and make a swc out of it, then use the swc instead of just the source code http://blog.another-d-mention.ro/programming/create-professional-flex-components/ .
HTH;
Amy
Those variables must be public. Variables are accessible from properties panel after setting them public.
public var field1:String;
public var field2:String;

Resources