Skip to Content

Agentry - bug in OpenUI demo app?

I'm trying my hand at OpenUI for the first time, and using the OpenUI demo app SMPAgentryClientFrameworkDemo provided by SAP to model my code after.  There seems to be a bug in the MyPotpourriEditAdapter class on iOS.  I build and run the app using the Xcode simulator, then on the initial window I go into the Miscellaneous section.  I then select one of the rows in the list and then click Edit.  The next screen is a listing of some of the adapters covered in MyPotpourriEditAdapter, such as Bool, unsigned integer, integer, etc. When I change any of the values and then click Cancel, the app fires off a NO assertion in the textFieldDidEndEditing method, which crashes the app.  Does anyone know if there is a bug in this demo app?  The adapter I need to model after is MyStringEditAdapter and it seems to have the same bug.

Thanks

Tim

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Oct 05, 2016 at 03:00 PM

    My goal is to create a custom String edit adapter class that will display a numeric keypad instead of the default alpha keypad.  I'm using the demo app as a starting point and just modifying MyPotpourriEditAdapter to fit my needs.  I was able to find a way to switch the keypad to numeric by using the UITextField's keyboardType property, which I'm setting in the loadView method.  However this bug is now causing me problems.

    I've noticed that you can work around the bug by forcing UITextField to resign its first responder status.  In the UITextField's textFieldShouldReturn method (which gets fired whenever the Return key is tapped while editing the text field) there is code to force it to resign first responder, like this:

    - (BOOL) textFieldShouldReturn:(UITextField*) textField

    {

         [textField resignFirstResponder];

         return YES;

    }

    So if you tap Return (and thereby forcing the text field to resign first responder) before tapping Cancel, then it seems to work around the bug.  So my theory is that if I force the text field to resign first responder any time the user taps on any other control on the screen then this will fix the problem.  However I can't find an event on UITextField in Apple's API (https://developer.apple.com/reference/uikit/uitextfield) that will fire whenever the field loses focus.

    I feel like there should be a simpler way to accomplish this goal.  Has anyone else run into the same issue with the OpenUI demo app, or know what the resolution to this would be?

    Thanks

    Add comment
    10|10000 characters needed characters exceeded

    • It's appearing more likely to me now that the way to work through this problem is to make sure that my UITextField resigns its first responder status as soon as any other control on the screen is tapped.  A way to do this is to override the screen ViewController method touchesBegan (an event which fires when one or more fingers touch the screen):

      - (void) touchesBegan:(NSSet *) touches withEvent:(UIEvent *) event

      {

           [textField resignFirstResponder];

      }


      However, I don't see a way to override this method on the screen ViewController since the source code implementation of the screen's ViewController is not provided in the SMPAgentryClientFrameworkSetup project.