Error CS1540 / CS0122: getting keyboard size does not work after switching to a unified API

Today I upgraded to Xamarin.iOS 8.6.0.51 and switched to a new one Unified API.

Now I want to get the keyboard size (this code worked before):

var val = new NSValue (notification.UserInfo.ValueForKey (UIKeyboard.FrameBeginUserInfoKey).Handle);
RectangleF keyboardSize = val.RectangleFValue;

Using the migration tool is RectangleFconverted to CGRect, but the errors that I get here are

Error CS1540: Unable to access protected member of Foundation.NSValue.NSValue(System.IntPtr)' via a qualifier of type Foundation.NSValue. The qualifier must be of type `MyApp.SomeViewController 'or derived from it (CS1540)

and

Error CS0122: `Foundation.NSValue.NSValue (System.IntPtr) 'is unavailable due to its protection level (CS0122)

? new NSValue(...), RectangleFValue , / .

Edit:

jonathanpeppers :

NSValue keyboardFrameBegin = (NSValue)notification.UserInfo.ValueForKey (UIKeyboard.FrameBeginUserInfoKey);
CGRect keyboardSize = keyboardFrameBegin.CGRectValue;

, , API, .

+4
2

:

var val = (NSValue)notification.UserInfo.ValueForKey (UIKeyboard.FrameBeginUserInfoKey);
RectangleF keyboardSize = val.RectangleFValue;

Xamarin.iOS.

, , , :

NSObject val = notification.UserInfo.ValueForKey (UIKeyboard.FrameBeginUserInfoKey);
Console.WriteLine("Type: " + val.GetType());
+8

.ctor(IntPtr) NSObject , . , @jonathanpeppers, (, ).

(, , ), , ObjCRuntime.Runtime.GetNSObject<T> (IntPtr) . NSObject -subclass.

+1

All Articles