Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
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
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.
In iOS Xcode it is possible to set the numberOfLines of all the UILabel instances by using the appearance, this is possible by doing this:
UILabel.appearance().numberOfLines = 2
In Visual Studio (both Mac and Windows) I try
UILabel.Appearance.Lines = 2;
But receive a message saying:
'UILabel.UILabelAppearance' does not contain a definition for 'Lines' and no extension method 'Lines' accepting a first argument of type 'UILabel.UILabelAppearance' could be found (are you missing a using directive or an assembly reference?)
Navigating to the implementation of the UILabelAppearance I can see that the Lines property is not listed only these:
==== Xamarin Information ====
Visual Studio Community 2017 for Mac
Version 7.0.1 (build 24)
Installation UUID: 1efa48e6-2eb5-4248-823d-5664a059f0d7
Mono 184.108.40.206 (2017-02/5077205) (64-bit)
GTK+ 2.24.23 (Raleigh theme)
Package version: 500010001
Runtime: Not installed
SDK: Not installed
MSBuild SDKs: /Library/Frameworks/Mono.framework/Versions/5.0.1/lib/mono/msbuild/15.0/bin/Sdks
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler
Version: 220.127.116.11 (Visual Studio Community)
Android SDK: /Users/APinedaMartinez/Library/Developer/Xamarin/android-sdk-macosx
Supported Android versions:
6.0 (API level 23)
SDK Tools Version: 25.2.5
SDK Platform Tools Version: 25.0.5
SDK Build Tools Version: 25.0.3
Java SDK: /usr
java version "1.8.0_101"
Java(TM) SE Runtime Environment (build 1.8.0_101-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.101-b13, mixed mode)
Android Designer EPL code available here:
Apple Developer Tools
Xcode 8.3 (12169)
Version: 10.10.0.36 (Visual Studio Community)
Build date: 2017-05-22 16:30:53-0400
Build date: Fri, 21 Apr 2017 17:57:12 GMT
Version: 18.104.22.168 (Visual Studio Community)
Release ID: 700010024
Git revision: 7ab1ca2ced6f584e56b7a0d4d321d00775cd95c9
Build date: 2017-05-19 05:44:51-04
Xamarin addins: 08d17158f3365beee5e60f67999e607cce4b3f93
Build lane: monodevelop-lion-d15-2
Mac OS X 10.12.5
Darwin 16.6.0 Darwin Kernel Version 16.6.0
Fri Apr 14 16:21:16 PDT 2017
This is because this selector is not decorated with an `UI_APPEARANCE_SELECTOR` macro, e.g. in UILabel.h
> @property(nonatomic) NSInteger numberOfLines;
unlike other properties in other types, e.g.
> @property(nonatomic) UIBarStyle barStyle UI_APPEARANCE_SELECTOR __TVOS_PROHIBITED; // default is UIBarStyleDefault
That means the selector is not supported for UIAppearance by Apple - but it will compile and _might_ work .
(a) Apple current appearance implementation (which might change and we've been told not to depend on) is a simple (currently unvalidated) proxy  to an instance of the type. So every selector can be used, even if they are not compatible (or related) with UIAppearance.
(b) ObjC is not type safe and the use of a macro (not types) hides this further. This means it will compile in ObjC just fine. Whether it will work (or not) varies per selector and iOS versions.
To avoid bad surprises the managed API provided in Xamarin.iOS.dll only expose the officially supported UIAppearance selectors (i.e. it use a custom type to enforce type safety).
Still want it ? Here's a workaround, subverting C# type safety, that does the same as the ObjC code you posted:
> var a = Runtime.GetNSObject<UILabel> (UILabel.Appearance.Handle);
> a.Lines = 2;
This treats the `UILabel.Appearance` (singleton) just like it was a normal `UILabel` (exactly like the ObjC code you posted) and match the current Apple implementation. As long as the ObjC code works then the C# version will behave identically.
 YMMV between selectors and iOS versions https://stackoverflow.com/a/11817191/220643 https://stackoverflow.com/a/11839198/220643
Thanks for the information, did not know this.
Hi. you stated that Ocj-c is not a type-safe language, hence the compilation with the "numberOfLines" property succeeds. but swift, which is a strongly typed language, does support the same property on UILabelAppearance.