Bug 13234 - UIStepper not behaving correctly
Summary: UIStepper not behaving correctly
Alias: None
Product: iOS
Classification: Xamarin
Component: Xamarin.iOS.dll ()
Version: 6.3.x
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2013-07-13 17:34 UTC by Paul Johnson
Modified: 2013-07-23 12:34 UTC (History)
2 users (show)

Is this bug a regression?: ---
Last known good build:

Test case (17.74 KB, application/zip)
2013-07-23 11:02 UTC, Paul Johnson

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Paul Johnson 2013-07-13 17:34:48 UTC
Using Xam.iOS Version: (Business Edition) on a Mac (Mountain Lion 0S 10.8.4)

If I create a UIStepper in Xcode and set it to be an outlet, I am able to set the properties correctly, the app compiles and the view works as it should.

If I create a UIStepper and set it to be an Action, I am unable to set the properties at all and the app dies before showing the view the stepper is on. 

It looks as if the steppers are instantiated correctly when they are an outlet, and not at all when they are an action. According to all of the examples I've found online, I should be able to still set the properties if the stepper is an action as well as link it to the ValueChanged event.
Comment 1 Rolf Bjarne Kvinge [MSFT] 2013-07-23 09:04:10 UTC
Can you attach a simple test app I can use to reproduce this?
Comment 2 Paul Johnson 2013-07-23 11:02:22 UTC
Created attachment 4403 [details]
Test case

Build and run. Click on the button and watch a null reference get thrown - the stepper isn't instantiated on the StepperBug view by the looks of it.

It works fine if it's set as an outlet rather than action.
Comment 3 Rolf Bjarne Kvinge [MSFT] 2013-07-23 11:50:56 UTC
In your sample, this code crashes:

    NavigationController.PushViewController(new StepperBug(), true);

because NavigationController is null. In fact it crashes even if StepperBug is never created, for example:

    NavigationController.ToString ();
Comment 4 Paul Johnson 2013-07-23 12:04:15 UTC
D'oh - quick example, sorry. If NavController is not null, the crash still exists.
Comment 5 Rolf Bjarne Kvinge [MSFT] 2013-07-23 12:06:52 UTC
In that case I get this exception:

Objective-C exception thrown.  Name: NSInvalidArgumentException Reason: -[StepperBug stepUpDown:]: unrecognized selector sent to instance 0x7c95a520

which is because StepperBug hasn't implemented the stepUpDown method. Adding this code to StepperBug.cs makes it work:

partial void stepUpDown (MonoTouch.Foundation.NSObject sender)
	Console.WriteLine ("stepUpDown");
Comment 6 Paul Johnson 2013-07-23 12:12:03 UTC
Right, so the behaviour is correct then? 

Surely any of the actions should auto generate a stub code then? Might be worth an addition in any case to the Xamarin docs on UIStepper (which isn't covered at all anywhere).

Comment 7 Rolf Bjarne Kvinge [MSFT] 2013-07-23 12:34:20 UTC
Yes, as far as I can see this is correct.

This is the way actions work: you have to implement the corresponding method yourself. We do generate a partial method declaration in the designer file so that you get code completion in your main file (type "partial " and a list of all the partial methods will show up). Note that this is not limited to UIStepper, it's the same for all actions.