summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Platform.iOS/Extensions/UIViewExtensions.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Xamarin.Forms.Platform.iOS/Extensions/UIViewExtensions.cs')
-rw-r--r--Xamarin.Forms.Platform.iOS/Extensions/UIViewExtensions.cs45
1 files changed, 9 insertions, 36 deletions
diff --git a/Xamarin.Forms.Platform.iOS/Extensions/UIViewExtensions.cs b/Xamarin.Forms.Platform.iOS/Extensions/UIViewExtensions.cs
index 8248af11..4c3eed98 100644
--- a/Xamarin.Forms.Platform.iOS/Extensions/UIViewExtensions.cs
+++ b/Xamarin.Forms.Platform.iOS/Extensions/UIViewExtensions.cs
@@ -2,15 +2,10 @@ using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
-using static System.String;
-#if __MOBILE__
using UIKit;
-namespace Xamarin.Forms.Platform.iOS
-#else
-using UIView = AppKit.NSView;
+using static System.String;
-namespace Xamarin.Forms.Platform.MacOS
-#endif
+namespace Xamarin.Forms.Platform.iOS
{
public static class UIViewExtensions
{
@@ -21,28 +16,15 @@ namespace Xamarin.Forms.Platform.MacOS
return self.Subviews.Concat(self.Subviews.SelectMany(s => s.Descendants()));
}
- public static SizeRequest GetSizeRequest(this UIView self, double widthConstraint, double heightConstraint,
- double minimumWidth = -1, double minimumHeight = -1)
+ public static SizeRequest GetSizeRequest(this UIView self, double widthConstraint, double heightConstraint, double minimumWidth = -1, double minimumHeight = -1)
{
- CoreGraphics.CGSize s;
-#if __MOBILE__
- s = self.SizeThatFits(new SizeF((float)widthConstraint, (float)heightConstraint));
-#else
- var control = self as AppKit.NSControl;
- if (control != null)
- s = control.SizeThatFits(new CoreGraphics.CGSize(widthConstraint, heightConstraint));
- else
- s = self.FittingSize;
-#endif
- var request = new Size(s.Width == float.PositiveInfinity ? double.PositiveInfinity : s.Width,
- s.Height == float.PositiveInfinity ? double.PositiveInfinity : s.Height);
- var minimum = new Size(minimumWidth < 0 ? request.Width : minimumWidth,
- minimumHeight < 0 ? request.Height : minimumHeight);
+ var s = self.SizeThatFits(new SizeF((float)widthConstraint, (float)heightConstraint));
+ var request = new Size(s.Width == float.PositiveInfinity ? double.PositiveInfinity : s.Width, s.Height == float.PositiveInfinity ? double.PositiveInfinity : s.Height);
+ var minimum = new Size(minimumWidth < 0 ? request.Width : minimumWidth, minimumHeight < 0 ? request.Height : minimumHeight);
return new SizeRequest(request, minimum);
}
- public static void SetBinding(this UIView view, string propertyName, BindingBase bindingBase,
- string updateSourceEventName = null)
+ public static void SetBinding(this UIView view, string propertyName, BindingBase bindingBase, string updateSourceEventName = null)
{
var binding = bindingBase as Binding;
//This will allow setting bindings from Xaml by reusing the MarkupExtension
@@ -69,7 +51,6 @@ namespace Xamarin.Forms.Platform.MacOS
view.AddObserver(nativePropertyListener, key, Foundation.NSKeyValueObservingOptions.New, IntPtr.Zero);
}
}
-#if __MOBILE__
catch (Foundation.MonoTouchException ex)
{
nativePropertyListener = null;
@@ -80,12 +61,7 @@ namespace Xamarin.Forms.Platform.MacOS
}
throw ex;
}
-#else
- catch (Exception ex)
- {
- throw ex;
- }
-#endif
+
}
NativeBindingHelpers.SetBinding(view, propertyName, bindingBase, nativePropertyListener);
@@ -101,8 +77,7 @@ namespace Xamarin.Forms.Platform.MacOS
NativeBindingHelpers.SetValue(target, targetProperty, value);
}
- public static void SetBindingContext(this UIView target, object bindingContext,
- Func<UIView, IEnumerable<UIView>> getChildren = null)
+ public static void SetBindingContext(this UIView target, object bindingContext, Func<UIView, IEnumerable<UIView>> getChildren = null)
{
NativeBindingHelpers.SetBindingContext(target, bindingContext, getChildren);
}
@@ -132,7 +107,6 @@ namespace Xamarin.Forms.Platform.MacOS
return null;
}
-#if __MOBILE__
internal static UIView FindFirstResponder(this UIView view)
{
if (view.IsFirstResponder)
@@ -147,6 +121,5 @@ namespace Xamarin.Forms.Platform.MacOS
return null;
}
-#endif
}
} \ No newline at end of file