Forum Xamarin.iOS

ShouldAutorotateToInterfaceOrientation event code gives warning in XS but not VS

I have the following code in all my view controllers:

[Obsolete("Deprecated in iOS6. Replace it with both GetSupportedInterfaceOrientations and PreferredInterfaceOrientationForPresentation", false)] public override bool ShouldAutorotateToInterfaceOrientation(UIInterfaceOrientation toInterfaceOrientation) // iOS4/iOS5 only { return true; }

It compiles without problems in Visual Studio 2012 with the latest stable Xamarin.iOS.

However in Xamarin.Studio (latest stable) on Mac OS X Mavericks I get compiler warnings about the "Obsolete" attribute. Why is that ?

If I comment the "Obsolete" attribute line it compiles without warnings in Xamarin.Studio but then Visual Studio starts to complain with warnings that I should add the "Obsolete" attribute back.

Has somebody else run into this problem with apps that need to be backwards compatible with iOS5 and earlier ?

Posts

  • sezamuzsezamuz BSMember ✭✭
    edited October 2013
    #pragma warning disable 612,618
    [Obsolete("Deprecated in iOS6. Replace it with both GetSupportedInterfaceOrientations and PreferredInterfaceOrientationForPresentation", false)]
    public override bool ShouldAutorotateToInterfaceOrientation(UIInterfaceOrientation toInterfaceOrientation)  // iOS4/iOS5 only
    {
        return true;
    }
    #pragma warning restore 612,618
    

    try this may be it work:
    http://stackoverflow.com/questions/10608309/disabling-obsolete-error-in-c-sharp

  • PerHungebergMllerPerHungebergMller DKMember ✭✭✭

    Thanx @sezamuz that helped :-)

  • PerHungebergMllerPerHungebergMller DKMember ✭✭✭

    @sezamuz

    I was a little to fast to conclude that it worked :(

    When building my solution in Xamarin.Studio I get the same warning.

    Warning CS0809: Obsolete member MyViewController.ShouldAutorotateToInterfaceOrientation(MonoTouch.UIKit.UIInterfaceOrientation)' overrides non-obsolete member MonoTouch.Dialog.DialogViewController.ShouldAutorotateToInterfaceOrientation(MonoTouch.UIKit.UIInterfaceOrientation)' (CS0809)

  • PerHungebergMllerPerHungebergMller DKMember ✭✭✭

    Actually the problem was in the code. For Monotouch.Dialog DialogViewController you should not use ShouldAutorotateToInterfaceOrientation(...) instead use the bool property AutoRotate instead.

    For normal UIViewController descendents the above #pragma trick works fine.

Sign In or Register to comment.