Bug 13238 - UIEdgeInsetsInsetRect not bound
Summary: UIEdgeInsetsInsetRect not bound
Status: RESOLVED FIXED
Alias: None
Product: iOS
Classification: Xamarin
Component: General ()
Version: 6.9.3.x
Hardware: PC Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Sebastien Pouliot
URL:
Depends on:
Blocks:
 
Reported: 2013-07-14 03:32 UTC by Pierce Boggan [MSFT]
Modified: 2014-01-06 07:38 UTC (History)
4 users (show)

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

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:
Status:
RESOLVED FIXED

Description Pierce Boggan [MSFT] 2013-07-14 03:32:20 UTC
Description of Issue: There really is no way to use UIEdgeInsetsInsetRect (because it isn't available), and there isn't a tidy way to workaround.
Comment 1 Sebastien Pouliot 2013-07-14 19:19:25 UTC
There's generally a 2 line workaround for missing p/invokes, in this case:

[DllImport (MonoTouch.Constants.UIKitLibrary)]
public extern static RectangleF UIEdgeInsetsInsetRect (RectangleF rect, UIEdgeInsets inset);

ref: http://developer.apple.com/library/ios/documentation/UIKit/Reference/UIKitFunctionReference/Reference/reference.html#//apple_ref/c/func/UIEdgeInsetsInsetRect

I'll add it to the UIEdgeInsets struct for newer releases, once I do/add some tests and check if other similar API could be missing. 

Anyway keep in mind this does not need to be a blocker for customers.
Comment 2 Sebastien Pouliot 2013-07-15 11:16:25 UTC
That above won't work since it's not a function but a macro. OTOH the macro [1] can easily be translated to C#:

		public RectangleF InsetRect (RectangleF rect, UIEdgeInsets insets)
		{
			return new RectangleF (rect.X + insets.Left,
			                       rect.Y + insets.Top,
			                       rect.Width - insets.Left - insets.Right,
			                       rect.Height - insets.Top - insets.Bottom);
		}

[1] found in /Applications/Xcode.app//Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.1.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIGeometry.h
Comment 3 Sebastien Pouliot 2013-07-22 15:06:35 UTC
Fixed in master-3.0 877af7b0af395e84639a4765c8d7863357999c43
QA: Unit tests added in the same revision
Comment 4 Fernando 2013-12-25 16:07:58 UTC
Why UIEdgeInsets.InsetRect takes only 1 parameter? or I am using the wrong method? I am trying to migrate a class from Objective C to C# and it uses UIEdgeInsetsInsetRect which takes two arguments while the RectInset I see in monotouch is tacking 1 argument. Thanks.
Comment 5 Rolf Bjarne Kvinge [MSFT] 2014-01-06 07:38:11 UTC
Fernando, it's because UIEdgeInsets.InsetRect is an instance method, so it does in fact that two parameters ('this' and the one you pass).

For example this in Objective-C:

    inset = UIEdgeInsetsInsetRect (edge_inset, rect);

would become this in C#:

    inset = edge_inset.InsetRect (rect);