User Defined Runtime Attribute

Hi,
How i can read user defined runtime attribute value?

I tried:
@Selector(“marginTop”)
@Property
public native String getMarginTop();

but it returns key (not value).

Thank you

Dear Ivan,

Could you please give us a bit more context: where is this attribute defined and how would you like to access it from Java? A more detailed code sample or even a fully runnable project would make it much easier to understand what you are trying to do.

Best Regards,
Gergely

I have a custom class which extends from UIImageView STImageView.
in xib I has:

            <imageView userInteractionEnabled="NO" contentMode="center" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="logo.png" translatesAutoresizingMaskIntoConstraints="NO" id="bhc-7x-yuP" userLabel="logo" customClass="STImageView">
                <rect key="frame" x="0.0" y="20" width="320" height="200"/>
                <constraints>
                    <constraint firstAttribute="height" constant="200" id="yIC-1b-c0X"/>
                </constraints>
                <userDefinedRuntimeAttributes>
                    <userDefinedRuntimeAttribute type="string" keyPath="marginTop" value="common_logo_margin_top"/>
                    <userDefinedRuntimeAttribute type="string" keyPath="marginLeft" value="common_logo_margin_left"/>
                    <userDefinedRuntimeAttribute type="string" keyPath="marginRight" value="common_logo_margin_right"/>
                </userDefinedRuntimeAttributes>
                <connections>
                    <outlet property="constraintMarginLeft" destination="49c-zI-bnP" id="eHK-8i-5RS"/>
                    <outlet property="constraintMarginRight" destination="GXz-Wi-DOQ" id="dfy-bY-Bjs"/>
                    <outlet property="constraintMarginTop" destination="hjD-bU-9K3" id="nfd-IV-dz3"/>
                </connections>
            </imageView>

On Java code I want have access to the values “common_logo_margin_top”, “common_logo_margin_left” etc.
I created property:
@Selector(“marginLeft”)
@Property
public native String getMarginLeft();

I call getMarginLeft() method in awakeFromNib(), but it returns key (marginLeft) but not value (common_logo_margin_left).

Thank you

Hi Ivan,

We could not reproduce this on our side.

Do you have these lines in your STImageView.h file?

@property NSString* marginTop;
@property NSString* marginLeft;
@property NSString* marginRight;

I understand what was the problem. I had on xib keys with ‘_’ (_marginTop etc.).
When I removed _ from xib and from java property everything start working.

Thanks for help.