Adding native orientation events

Our next step is to add the notifications that are going to fire every time an orientation occurs. These events will come from the native side, so in order to have these pass down to our Xamarin.Forms project, we are going to use the static events on the OrientationPage.

Let's start with the iOS project. Open the AppDelegate.cs file and add the following function:

 public override void DidChangeStatusBarOrientation(UIApplication application, UIInterfaceOrientation oldStatusBarOrientation) { // change listview opacity based upon orientation switch (UIApplication.SharedApplication.StatusBarOrientation) { case UIInterfaceOrientation.Portrait: case UIInterfaceOrientation.PortraitUpsideDown: OrientationPage.NotifyOrientationChange(Orientation.Portrait); ...

Get Xamarin Blueprints now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.