public override void ViewWillAppear(bool animated) { base.ViewWillAppear(animated); // Set the appropriate toolbarItems based on the mediaType of the asset. if (Asset.MediaType == PHAssetMediaType.Video) { ShowPlaybackToolbar(); } else { ShowStaticToolbar(); } // Enable the edit button if the asset can be edited. bool isEditable = Asset.CanPerformEditOperation(PHAssetEditOperation.Properties) || Asset.CanPerformEditOperation(PHAssetEditOperation.Content); EditButton.Enabled = isEditable; // Enable the trash button if the asset can be deleted. bool isTrashable = AssetCollection != null? AssetCollection.CanPerformEditOperation(PHCollectionEditOperation.RemoveContent) : Asset.CanPerformEditOperation(PHAssetEditOperation.Delete); TrashButton.Enabled = isTrashable; UpdateImage(); View.LayoutIfNeeded(); }
public override void ViewWillAppear(bool animated) { base.ViewWillAppear(animated); // Set the appropriate toolbarItems based on the mediaType of the asset. if (Asset.MediaType == PHAssetMediaType.Video) { #if __IOS__ && !__TVOS__ ToolbarItems = new UIBarButtonItem [] { FavoriteButton, Space, PlayButton, Space, TrashButton }; if (NavigationController != null) { NavigationController.ToolbarHidden = false; } #elif __TVOS__ NavigationItem.LeftBarButtonItems = new UIBarButtonItem [] { PlayButton, FavoriteButton, TrashButton }; #endif } else { // Live Photos have their own playback UI, so present them like regular photos, just like Photos app #if __IOS__ && !__TVOS__ ToolbarItems = new UIBarButtonItem [] { FavoriteButton, Space, TrashButton }; if (NavigationController != null) { NavigationController.ToolbarHidden = false; } #elif __TVOS__ NavigationItem.LeftBarButtonItems = new UIBarButtonItem [] { FavoriteButton, TrashButton }; #endif } // Enable editing buttons if the asset can be edited. EditButton.Enabled = Asset.CanPerformEditOperation(PHAssetEditOperation.Content); FavoriteButton.Enabled = Asset.CanPerformEditOperation(PHAssetEditOperation.Properties); FavoriteButton.Title = Asset.Favorite ? "♥︎" : "♡"; // Enable the trash button if the asset can be deleted. if (AssetCollection != null) { TrashButton.Enabled = AssetCollection.CanPerformEditOperation(PHCollectionEditOperation.RemoveContent); } else { TrashButton.Enabled = Asset.CanPerformEditOperation(PHAssetEditOperation.Delete); } // Make sure the view layout happens before requesting an image sized to fit the view. View.LayoutIfNeeded(); UpdateImage(); }