[MonoTouch] Problem with UISegmentedControl on iPad

Craig Dunn craig.dunn at conceptdevelopment.net
Mon Mar 19 21:47:31 UTC 2012


What iOS version is your iPad running?
ApportionsSegmentWidthsByContent is iOS5 only. Using that property seems to
work on my iPad with iOS5.1 installed...

You could try something like this to avoid 'unknown selector' errors

if (*yourSegmentedControl*.RespondsToSelector(new
MonoTouch.ObjCRuntime.Selector("apportionsSegmentWidthsByContent"))) {

mapTypes.ApportionsSegmentWidthsByContent = true;

}


Roy - i think obj-c "properties" follow that standard where the getter has
the 'name' of the property and the setter has the 'set' prefix...

HTH
cd


On Tue, Mar 20, 2012 at 8:17 AM, Dean Cleaver <
dean.cleaver at xceptionsoftware.com> wrote:

> Am trying to set the UISegmentedControl to
> ApportionsSegmentWidthsByContent = true and it crashes on the iPad -
> doesn't crash in the simulator (iPhone) nor on my iPhone devices. Any ideas
> why the difference?
>
> MonoTouch.Foundation.MonoTouchException: Objective-C exception thrown.
>  Name: NSInvalidArgumentException Reason: -[UISegmentedControl
> setApportionsSegmentWidthsByContent:]: unrecognized selector sent to
> instance 0x868fc80
>  at
> MonoTouch.UIKit.UISegmentedControl.set_ApportionsSegmentWidthsByContent
> (Boolean value) [0x00000] in <filename unknown>:0
>  at
> KleverLogic.FlashValet.iPhone.Valet.Common.ReceiptViewController.ViewDidLoad
> () [0x00374] in
> /xsl-home/kleverlogic/FlashValet/Mobile/iPhone/Valet/Common/ReceiptViewController.cs:103
>
> _______________________________________________
> MonoTouch mailing list
> MonoTouch at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/monotouch
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ximian.com/pipermail/monotouch/attachments/20120320/68f0dafe/attachment-0001.html>


More information about the MonoTouch mailing list