Search code examples
iospickersmartface.io

Trying to get a picker{} to show in SmartFace App Studio


I have been using the example code from SmartFace.io to work as follows:

    pick(
    myCars,
    selectedIndex,
    function(e) {Pages.NewPage.Label1.text = myCars[e.index]; selectedIndex = e.index; },
    function() {},
    function() {}
 );

However the picker just doesn't want to show in the emulator. I have also tryied putting this code in a sepparate function and call it from a OnPress event of an ImageButton but still nothing.

I am trying this on an iPhone 4S so maybe that is the issue...

Any hint on what I am doing incorrectly would be greatly appreciated.

Thanks Gerry


Solution

  • I just add a TextButton and Label to Page1 and write these codeLines. and it works; Maybe, some other codes breaks the functions.

    var myCars = ["Audi", "Volvo", "Volkswagon"]; 
    var selectedIndex = 0;
    
    /**
    * Creates action(s) that are run when the user press the key of the devices.
    * @param {KeyCodeEventArguments} e Uses to for key code argument. It returns e.keyCode parameter.
    * @this SMF.UI.Page
    */
    function Page1_Self_OnKeyPress(e) {
        if (e.keyCode === 4) {
            Application.exit();
        }
    }
    /**
    * Creates action(s) that are run when the page is appeared
    * @param {EventArguments} e Returns some attributes about the specified functions
    * @this SMF.UI.Page
    */
    function Page1_Self_OnShow() {
        //Comment following block for removing navigationbar/actionbar sample
        //Copy this code block to every page onShow
        header.init(this);
        header.setTitle("Page1");
        header.setRightItem("RItem");
        header.setLeftItem();
        /**/
    }
    /**
    * Creates action(s) that are run when the object is pressed from device's screen.
    * @param {EventArguments} e Returns some attributes about the specified functions
    * @this SMF.UI.TextButton
    */
    function Page1_TextButton1_OnPressed(e){
          pick(
        myCars,
        selectedIndex,
        function(e) {Pages.NewPage.Label1.text = myCars[e.index]; selectedIndex = e.index; },
        function() {},
        function() {}
     );
    }